Subject: Built motion from commit 22bc4a4.|0.0.19
From: Motion Team <[email-masked]>
Date: Mon, 11 Jan 2016 19:22:29 +0000 (+0100)

Built motion from commit 22bc4a4.|0.0.19
---

diff --git a/package.json b/package.json
index 497d188..381fdd7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "motion",
-  "version": "0.0.19",
+  "version": "0.0.20",
   "main": "server/app.js",
   "dependencies": {
     "accept-language-parser": "^1.0.2",
@@ -111,6 +111,7 @@
     "grunt-version": "^1.0.0",
     "grunt-wiredep": "~2.0.0",
     "jit-grunt": "^0.9.1",
+    "js-obfuscator": "^0.1.1",
     "jshint-stylish": "~2.0.1",
     "karma": "~0.13.2",
     "karma-chrome-launcher": "~0.2.0",
diff --git a/release-notes/changelog_0.0.18.txt b/release-notes/changelog_0.0.19.txt
similarity index 93%
rename from release-notes/changelog_0.0.18.txt
rename to release-notes/changelog_0.0.19.txt
index 2be4f73..c95dcc5 100644
--- a/release-notes/changelog_0.0.18.txt
+++ b/release-notes/changelog_0.0.19.txt
@@ -23,5 +23,4 @@
 - * 2f5d1bc - 2016-01-05: Market update (item disposition) 
 - * 41cb71c - 2016-01-05: Update integration: model, route Update market: fake market only with our integrations Add mocha as dev dependencies 
 - * fa560ae - 2016-01-05: add danger notification (xAlert) 
-- * ce14827 - 2016-01-04: Ui grid table with remote sorting, filtering and grouping for reports. 
 
diff --git a/server/api/agent/agent.controller.js b/server/api/agent/agent.controller.js
index a85f147..21b3367 100644
--- a/server/api/agent/agent.controller.js
+++ b/server/api/agent/agent.controller.js
@@ -1,279 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var Agent = require('../../models').User;
-var Team = require('../../models').Team;
-
-// Get list of agents
-exports.index = function(req, res, next) {
-
-  var attributes = ['fullname', 'name', 'email'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {
-      role: 'agent'
-    },
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Agent
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single agent
-exports.show = function(req, res) {
-  Agent
-    .findById(req.params.id)
-    .then(function(agent) {
-      if (!agent) {
-        return res.sendStatus(404);
-      }
-      return res.send(agent);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Validate the existence of an internal number
-exports.internalValidation = function(req, res) {
-  Agent
-    .findAll({
-      where: {
-        internal: req.body.internal
-      }
-    })
-    .then(function(internals) {
-      if (!internals) {
-        return res.sendStatus(404);
-      }
-      return res.send(internals);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new agent in the DB.
-exports.create = function(req, res) {
-  Agent
-    .create(req.body)
-    .then(function(agent) {
-      Team
-        .findOne({
-          where: {
-            defaultEntry: true
-          }
-        })
-        .then(function(team) {
-          team
-            .addUser(agent.id)
-            .then(function() {
-              return res.status(201).send(agent);
-            })
-            .catch(function(err) {
-              console.log(err);
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          console.log(err);
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      console.log(err);
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing agent in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Agent
-    .findById(req.params.id)
-    .then(function(agent) {
-      if (!agent) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(agent, req.body);
-      updated
-        .save()
-        .then(function() {
-          return res.status(200).send(agent);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.destroy = function(req, res) {
-  Agent
-    .findById(req.params.id)
-    .then(function(agent) {
-      if (!agent) {
-        return res.sendStatus(404);
-      }
-      agent.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function(req, res) {
-  Agent
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-/**
- * Change an agent password
- */
-exports.changePassword = function(req, res, next) {
-  console.log(req.body);
-  var agentId = req.user.id;
-  var oldPass = String(req.body.oldPassword);
-  var newPass = String(req.body.newPassword);
-  Agent
-    .findById(agentId)
-    .then(function(agent) {
-      if (agent.authenticate(oldPass)) {
-        agent.password = newPass;
-        agent.save()
-          .then(function() {
-            res.status(200).send(agent);
-          })
-          .catch(function(err) {
-            return next(err);
-          });
-      } else {
-        res.sendStatus(403);
-      }
-    });
-};
-
-/**
- * Change an agent password by admin
- */
-exports.resetPassword = function(req, res, next) {
-  var newPass = String(req.body.newPassword);
-  Agent
-    .findById(req.params.id)
-    .then(function(user) {
-      user.password = newPass;
-      user.save()
-        .then(function() {
-          res.status(200).send(user);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    });
-};
-
-exports.agentValidation = function(req, res) {
-  var where = {};
-  where[req.params.field] = req.body.value;
-  Agent
-    .findAndCountAll({
-      where: where
-    })
-    .then(function(result) {
-      if (result.count) {
-        return res.status(200).send({
-          isValid: false,
-          value: req.body.value
-        });
-      }
-      return res.status(200).send({
-        isValid: true,
-        value: req.body.value
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/agent/agent.socket.js b/server/api/agent/agent.socket.js
index 5535cb7..4cc1c99 100644
--- a/server/api/agent/agent.socket.js
+++ b/server/api/agent/agent.socket.js
@@ -1,33 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var agent = require('../../models').User;
-
-exports.register = function(socket) {
-  agent.afterCreate(function(doc) {
-    if (doc.role === 'agent') {
-      onSave(socket, doc);
-    }
-  });
-  agent.afterUpdate(function(doc) {
-    if (doc.role === 'agent') {
-      onSave(socket, doc);
-    }
-  });
-  agent.afterDestroy(function(doc) {
-    if (doc.role === 'agent') {
-      onRemove(socket, doc);
-    }
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('agent:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('agent:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/agent/agent.spec.js b/server/api/agent/agent.spec.js
index e6c4651..52fb972 100644
--- a/server/api/agent/agent.spec.js
+++ b/server/api/agent/agent.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/agents', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/agents')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/agent/index.js b/server/api/agent/index.js
index f2a2a93..0210262 100644
--- a/server/api/agent/index.js
+++ b/server/api/agent/index.js
@@ -1,21 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./agent.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/validate/:field', auth.isAuthenticated(), controller.agentValidation);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.internalValidation);
-router.put('/password', auth.isAuthenticated(), controller.changePassword);
-router.put('/password/:id/reset', auth.isAuthenticated(), auth.hasRole('admin'), controller.resetPassword);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/ami/ami.ami.js b/server/api/ami/ami.ami.js
index 2684197..344bfaa 100644
--- a/server/api/ami/ami.ami.js
+++ b/server/api/ami/ami.ami.js
@@ -1,37 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Ami = require('../../models').Ami;
-var async = require('async');
-var _ = require('lodash');
-
-var ami = null;
-
-exports.register = function(ami) {
-  this.ami = ami;
-}
-
-exports.action = function(action, cb) {
-  if (this.ami && this.ami.isConnected()) {
-    this.ami.action(action, function(err, res) {
-      if (err) {
-        cb(err);
-      }
-      var data = _.merge(res, action);
-      Ami
-        .create(data)
-        .then(function(ami) {
-          cb(null, ami)
-        })
-        .catch(function(err) {
-          return cb(err);
-        });
-
-    });
-  } else {
-    cb(new Error('Asterisk Manager disconnected..'));
-  }
-}
\ No newline at end of file
diff --git a/server/api/ami/ami.controller.js b/server/api/ami/ami.controller.js
index dc409ab..cb6f135 100644
--- a/server/api/ami/ami.controller.js
+++ b/server/api/ami/ami.controller.js
@@ -1,101 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Ami = require('../../models').Ami;
-
-// Get list of amis
-exports.index = function(req, res) {
-  Ami
-    .findAll()
-    .then(function(amis) {
-      return res.status(200).send(amis);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single ami
-exports.show = function(req, res) {
-  Ami
-    .findById(req.params.id)
-    .then(function(ami) {
-      if (!ami) {
-        return res.sendStatus(404);
-      }
-      return res.send(ami);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new ami in the DB.
-exports.create = function(req, res) {
-
-  req.body.data = JSON.stringify(req.body);
-  req.body.UserId = req.user.id;
-
-  require('./ami.ami').action(req.body, function(err, result) {
-    if (err) {
-      handleError(res, err);
-    } else {
-      return res.status(201).send(result);
-    }
-  });
-
-};
-
-// Updates an existing ami in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Ami
-    .findById(req.params.id)
-    .then(function(ami) {
-      if (!ami) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(ami, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(ami);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a ami from the DB.
-exports.destroy = function(req, res) {
-  Ami
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(ami) {
-      if (!ami) {
-        return res.sendStatus(404);
-      }
-      ami.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/ami/ami.socket.js b/server/api/ami/ami.socket.js
index 6047274..f0d79f2 100644
--- a/server/api/ami/ami.socket.js
+++ b/server/api/ami/ami.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Ami = require('../../models').Ami;
-
-exports.register = function(socket) {
-  Ami.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  Ami.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('ami:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('ami:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/ami/ami.spec.js b/server/api/ami/ami.spec.js
index a7502d7..3be4e4e 100644
--- a/server/api/ami/ami.spec.js
+++ b/server/api/ami/ami.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/ami', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/ami')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/ami/index.js b/server/api/ami/index.js
index b926b75..636474e 100644
--- a/server/api/ami/index.js
+++ b/server/api/ami/index.js
@@ -1,16 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./ami.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-// router.get('/:id', controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-// router.put('/:id', controller.update);
-// router.patch('/:id', controller.update);
-// router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/automation/automation.controller.js b/server/api/automation/automation.controller.js
index dc50214..a3315fc 100644
--- a/server/api/automation/automation.controller.js
+++ b/server/api/automation/automation.controller.js
@@ -1,168 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var Automation = require('../../models').Automation;
-
-// Get list of agents
-exports.index = function(req, res, next) {
-
-  var attributes = ['fullname', 'name', 'email'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Automation
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single Automation
-exports.show = function(req, res) {
-  Automation
-    .findById(req.params.id)
-    .then(function(Automation) {
-      if (!Automation) {
-        return res.sendStatus(404);
-      }
-      return res.send(Automation);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new Automation in the DB.
-exports.create = function(req, res, next) {
-  Automation
-    .create(req.body)
-    .then(function() {
-      return res.sendStatus(201);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing Automation in the DB.
-exports.update = function(req, res, next) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Automation
-    .findById(req.params.id)
-    .then(function(Automation) {
-      if (!Automation) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(Automation, req.body);
-      updated
-        .save()
-        .then(function() {
-          return res.status(200).send(Automation);
-        })
-        .catch(function(err) {
-          // return handleError(res, err);
-          return next(err);
-
-        });
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Deletes a Automation from the DB.
-exports.destroy = function(req, res) {
-  Automation
-    .findById(req.params.id)
-    .then(function(Automation) {
-      if (!Automation) {
-        return res.sendStatus(404);
-      }
-      Automation.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-}
-
-exports.bulkDestroy = function(req, res) {
-  Automation
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/automation/automation.socket.js b/server/api/automation/automation.socket.js
index 2c55b60..b27b737 100644
--- a/server/api/automation/automation.socket.js
+++ b/server/api/automation/automation.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Automation = require('../../models').Automation;
-
-exports.register = function(socket) {
-  Automation.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Automation.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('automation:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('automation:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/automation/automation.spec.js b/server/api/automation/automation.spec.js
index ab8c5b4..de6ef55 100644
--- a/server/api/automation/automation.spec.js
+++ b/server/api/automation/automation.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/automations', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/automations')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/automation/index.js b/server/api/automation/index.js
index 98acf5a..9179c75 100644
--- a/server/api/automation/index.js
+++ b/server/api/automation/index.js
@@ -1,17 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./automation.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/business_action/business_action.controller.js b/server/api/business_action/business_action.controller.js
index 53338c4..fcc6f67 100644
--- a/server/api/business_action/business_action.controller.js
+++ b/server/api/business_action/business_action.controller.js
@@ -1,94 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var BusinessAction = require('../../models').BusinessAction;
-
-// Get list of business_actions
-exports.index = function(req, res) {
-  BusinessAction
-    .findAll()
-    .then(function(business_actions) {
-      return res.status(200).send(business_actions);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single businessAction
-exports.show = function(req, res) {
-  BusinessAction
-    .findById(req.params.id)
-    .then(function(businessAction) {
-      if (!businessAction) {
-        return res.sendStatus(404);
-      }
-      return res.send(businessAction);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new businessAction in the DB.
-exports.create = function(req, res) {
-  BusinessAction
-    .create(req.body)
-    .then(function(businessAction) {
-      return res.status(201).send(businessAction);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing businessAction in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  BusinessAction
-    .findById(req.params.id)
-    .then(function(businessAction) {
-      if (!businessAction) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(businessAction, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(businessAction);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a businessAction from the DB.
-exports.destroy = function(req, res) {
-  BusinessAction
-    .findById(req.params.id)
-    .then(function(businessAction) {
-      if (!businessAction) {
-        return res.sendStatus(404);
-      }
-      businessAction
-        .destroy()
-        .then(function() {
-          return res.status(200).send(businessAction);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/business_action/business_action.socket.js b/server/api/business_action/business_action.socket.js
index 3fecc0c..cf16d67 100644
--- a/server/api/business_action/business_action.socket.js
+++ b/server/api/business_action/business_action.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var BusinessAction = require('../../models').BusinessAction;
-
-exports.register = function(socket) {
-  BusinessAction.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  BusinessAction.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('business_action:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('business_action:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/business_action/business_action.spec.js b/server/api/business_action/business_action.spec.js
index 4b677be..7862254 100644
--- a/server/api/business_action/business_action.spec.js
+++ b/server/api/business_action/business_action.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/business/actions', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/business/actions')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/business_action/index.js b/server/api/business_action/index.js
index 3545d75..96596ca 100644
--- a/server/api/business_action/index.js
+++ b/server/api/business_action/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./business_action.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/business_condition/business_condition.controller.js b/server/api/business_condition/business_condition.controller.js
index d480f8e..8a1ada0 100644
--- a/server/api/business_condition/business_condition.controller.js
+++ b/server/api/business_condition/business_condition.controller.js
@@ -1,93 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var BusinessCondition = require('../../models').BusinessCondition;
-
-// Get list of business_conditions
-exports.index = function(req, res) {
-  BusinessCondition
-  .findAll()
-  .then(function (business_conditions) {
-    return res.status(200).send(business_conditions);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Get a single business_condition
-exports.show = function(req, res) {
-  BusinessCondition
-  .findById(req.params.id)
-  .then(function (business_condition) {
-    if(!business_condition) { return res.sendStatus(404); }
-    return res.send(business_condition);
-  })
-  .catch(function(err){
-    return handleError(res, err);
-  });
-};
-
-// Creates a new business_condition in the DB.
-exports.create = function(req, res) {
-  BusinessCondition
-  .create(req.body)
-  .then(function(business_condition) {
-    return res.status(201).send(business_condition);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Updates an existing business_condition in the DB.
-exports.update = function(req, res) {
-  if(req.body.id) { delete req.body.id; }
-  BusinessCondition
-  .find({
-    where: {
-      id: req.params.id
-    }
-  })
-  .then(function (business_condition) {
-    if(!business_condition) { return res.sendStatus(404); }
-    var updated = _.merge(business_condition, req.body);
-    updated.save()
-    .then(function () {
-      return res.status(200).send(business_condition);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Deletes a business_condition from the DB.
-exports.destroy = function(req, res) {
-  BusinessCondition
-  .find({
-    where: {
-      id: req.params.id
-    }
-  })
-  .then(function (business_condition) {
-    if(!business_condition) { return res.sendStatus(404); }
-    business_condition.destroy()
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/business_condition/business_condition.socket.js b/server/api/business_condition/business_condition.socket.js
index c904ed1..d9f53a0 100644
--- a/server/api/business_condition/business_condition.socket.js
+++ b/server/api/business_condition/business_condition.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var BusinessCondition = require('../../models').BusinessCondition;
-
-exports.register = function(socket) {
-  BusinessCondition.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  BusinessCondition.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('business_condition:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('business_condition:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/business_condition/business_condition.spec.js b/server/api/business_condition/business_condition.spec.js
index 76ad269..4777bce 100644
--- a/server/api/business_condition/business_condition.spec.js
+++ b/server/api/business_condition/business_condition.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/business/conditions', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/business/conditions')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/business_condition/index.js b/server/api/business_condition/index.js
index 71a1e3f..262d540 100644
--- a/server/api/business_condition/index.js
+++ b/server/api/business_condition/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./business_condition.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/chat_application/chat_application.controller.js b/server/api/chat_application/chat_application.controller.js
index 9c2085d..4950dda 100644
--- a/server/api/chat_application/chat_application.controller.js
+++ b/server/api/chat_application/chat_application.controller.js
@@ -1,105 +1 @@
-'use strict';
-var _ = require('lodash');
-var ChatApplication = require('../../models').ChatApplication;
-// Get list of chat_applications
-exports.index = function(req, res) {
-  ChatApplication
-    .findAll({
-      where: req.query,
-      order: 'priority',
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(chat_applications) {
-      return res.status(200).send(chat_applications);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-// Get a single chat_application
-exports.show = function(req, res) {
-  ChatApplication
-    .findById(req.params.id)
-    .then(function(chat_application) {
-      if (!chat_application) {
-        return res.sendStatus(404);
-      }
-      return res.send(chat_application);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-// Creates a new chat_application in the DB.
-exports.create = function(req, res, next) {
-  ChatApplication.max('priority', {
-    where: {
-      ChatWebsiteId: req.body.ChatWebsiteId
-    }
-  }).then(function(max) {
-    // SET PRIORITY
-    req.body.priority = max ? ++max : 1;
-    ChatApplication
-      .create(req.body)
-      .then(function(mailApplication) {
-        return res.status(201).send(mailApplication);
-      })
-      .catch(function(err) {
-        return next(err);
-      });
-  }).catch(function(err) {
-    next(err);
-  });
-};
-// Updates an existing chat_application in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ChatApplication
-    .findById(req.params.id)
-    .then(function(chat_application) {
-      if (!chat_application) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(chat_application, req.body);
-      updated
-        .save()
-        .then(function() {
-          return res.status(200).send(chat_application);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-// Deletes a chat_application from the DB.
-exports.destroy = function(req, res) {
-  ChatApplication
-    .findById(req.params.id)
-    .then(function(chat_application) {
-      if (!chat_application) {
-        return res.sendStatus(404);
-      }
-      chat_application
-        .destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/chat_application/chat_application.socket.js b/server/api/chat_application/chat_application.socket.js
index 8776f3a..3b74ac7 100644
--- a/server/api/chat_application/chat_application.socket.js
+++ b/server/api/chat_application/chat_application.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ChatApplication = require('../../models').ChatApplication;
-
-exports.register = function(socket) {
-  ChatApplication.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  ChatApplication.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('chat_application:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('chat_application:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/chat_application/chat_application.spec.js b/server/api/chat_application/chat_application.spec.js
index 215f533..dcb3245 100644
--- a/server/api/chat_application/chat_application.spec.js
+++ b/server/api/chat_application/chat_application.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/chat/applications', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/chat/applications')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/chat_application/index.js b/server/api/chat_application/index.js
index d85a510..f6af931 100644
--- a/server/api/chat_application/index.js
+++ b/server/api/chat_application/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./chat_application.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/chat_enquiry/enquiry.controller.js b/server/api/chat_enquiry/enquiry.controller.js
index 17edcbc..8a4fabd 100644
--- a/server/api/chat_enquiry/enquiry.controller.js
+++ b/server/api/chat_enquiry/enquiry.controller.js
@@ -1,99 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ChatEnquiry = require('../../models').ChatEnquiry;
-var ChatVisitor = require('../../models').ChatVisitor;
-
-// Get list of enquirys
-exports.index = function(req, res) {
-  ChatEnquiry
-    .findAll()
-    .then(function(enquirys) {
-      return res.status(200).send(enquirys);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single enquiry
-exports.show = function(req, res) {
-  ChatEnquiry
-    .findOne({
-      where: {
-        id: req.params.id
-      },
-      include: [ChatVisitor]
-    })
-    .then(function(enquiry) {
-      if (!enquiry) {
-        return res.sendStatus(404);
-      }
-      return res.send(enquiry);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new enquiry in the DB.
-exports.create = function(req, res) {
-  ChatEnquiry
-    .create(req.body)
-    .then(function(enquiry) {
-      return res.status(201).send(enquiry);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing enquiry in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ChatEnquiry
-    .findById(req.params.id)
-    .then(function(enquiry) {
-      if (!enquiry) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(enquiry, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(enquiry);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a enquiry from the DB.
-exports.destroy = function(req, res) {
-  ChatEnquiry
-    .findById(req.params.id)
-    .then(function(enquiry) {
-      if (!enquiry) {
-        return res.sendStatus(404);
-      }
-      enquiry.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/chat_enquiry/enquiry.socket.js b/server/api/chat_enquiry/enquiry.socket.js
index b7b69e1..da30681 100644
--- a/server/api/chat_enquiry/enquiry.socket.js
+++ b/server/api/chat_enquiry/enquiry.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var enquiry = require('../../models').ChatEnquiry;
-
-exports.register = function(socket) {
-  enquiry.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  enquiry.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('enquiry:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('enquiry:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/chat_enquiry/index.js b/server/api/chat_enquiry/index.js
index 547b695..f0383d4 100644
--- a/server/api/chat_enquiry/index.js
+++ b/server/api/chat_enquiry/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./enquiry.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/chat_message/chat_message.controller.js b/server/api/chat_message/chat_message.controller.js
index 958ca19..fa657c4 100644
--- a/server/api/chat_message/chat_message.controller.js
+++ b/server/api/chat_message/chat_message.controller.js
@@ -1,267 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var md5 = require('md5');
-
-var User = require('../../models').User;
-var ChatRoom = require('../../models').ChatRoom;
-var ChatMessage = require('../../models').ChatMessage;
-var ChatVisitor = require('../../models').ChatVisitor;
-
-// Get list of chat_messages
-exports.index = function (req, res) {
-  ChatMessage
-    .findAll()
-    .then(function (chat_messages) {
-      return res.status(200).send(chat_messages);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single chatMessage
-exports.show = function (req, res) {
-  ChatMessage
-    .findById(req.params.id)
-    .then(function (chatMessage) {
-      if (!chatMessage) {
-        return res.sendStatus(404);
-      }
-      return res.send(chatMessage);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new chatMessage in the DB.
-exports.create = function (req, res, next) {
-  // if (req.body.ChatRoomId && req.body.to) {
-  //   return handleError(res, new Error('Select ChatRoomId or to'));
-  // } else if (req.body.to) {
-  //
-  //   switch (req.body.type) {
-  //     case 'internal':
-  //       User
-  //         .findOne({
-  //           where: {
-  //             $or: [{
-  //               id: {
-  //                 $like: req.body.to
-  //               }
-  //             }, {
-  //               name: req.body.to
-  //             }]
-  //           }
-  //         })
-  //         .then(function(user) {
-  //           if (user) {
-  //
-  //             var users = _.sortBy([user, req.user], 'id');
-  //             var participants = {
-  //               users: {
-  //                 ids: [users[0].id, users[1].id]
-  //               },
-  //               visitors: {
-  //                 ids: []
-  //               }
-  //             };
-  //
-  //             var token = md5(JSON.stringify(participants)).toString(
-  //               'base64');
-  //
-  //             participants.users.fullnames = [users[0].fullname, users[1].fullname];
-  //             participants.visitors.fullnames = [];
-  //
-  //             ChatRoom
-  //               .findOrCreate({
-  //                 where: {
-  //                   token: token
-  //                 },
-  //                 defaults: {
-  //                   type: req.body.type,
-  //                   token: token,
-  //                   participants: JSON.stringify(participants)
-  //                 }
-  //               })
-  //               .spread(function(chatRoom, created) {
-  //
-  //                 chatRoom
-  //                   .updateAttributes({
-  //                     participants: JSON.stringify(participants)
-  //                   });
-  //
-  //                 ChatMessage
-  //                   .create({
-  //                     body: req.body.body,
-  //                     fullname: req.user.fullname,
-  //                     email: req.user.email,
-  //                     ChatRoomId: chatRoom.id,
-  //                     userId: req.user.id
-  //                   })
-  //                   .then(function(chatMessage) {
-  //                     return res.status(201).send(chatMessage);
-  //                   })
-  //                   .catch(function(err) {
-  //                     return handleError(res, err);
-  //                   });
-  //               });
-  //
-  //           } else {
-  //             return handleError(res, new Error('User not found'));
-  //           }
-  //         })
-  //         .catch(function(err) {
-  //           return handleError(res, err);
-  //         });
-  //
-  //       break;
-  //     case 'external':
-  //       ChatVisitor
-  //         .findOne({
-  //           where: {
-  //             $or: [{
-  //               id: {
-  //                 $like: req.body.to
-  //               }
-  //             }, {
-  //               fullname: req.body.to
-  //             }]
-  //           }
-  //         })
-  //         .then(function(chatVisitor) {
-  //           if (chatVisitor) {
-  //
-  //             var participants = {
-  //               users: {
-  //                 ids: [req.user.id]
-  //               },
-  //               visitors: {
-  //                 ids: [chatVisitor.id]
-  //               }
-  //             };
-  //
-  //             var token = md5(JSON.stringify(participants)).toString(
-  //               'base64');
-  //
-  //             participants.users.fullnames = [req.user.fullname];
-  //             participants.visitors.fullnames = [chatVisitor.fullname];
-  //
-  //             ChatRoom
-  //               .findOrCreate({
-  //                 where: {
-  //                   token: token
-  //                 },
-  //                 defaults: {
-  //                   type: req.body.type,
-  //                   token: token,
-  //                   participants: JSON.stringify(participants)
-  //                 }
-  //               })
-  //               .spread(function(chatRoom, created) {
-  //
-  //                 chatRoom
-  //                   .updateAttributes({
-  //                     participants: JSON.stringify(participants)
-  //                   });
-  //
-  //                 ChatMessage
-  //                   .create({
-  //                     body: req.body.body,
-  //                     fullname: req.user.fullname,
-  //                     email: req.user.email,
-  //                     ChatRoomId: chatRoom.id,
-  //                     userId: req.user.id
-  //                   })
-  //                   .then(function(chatMessage) {
-  //                     return res.status(201).send(chatMessage);
-  //                   })
-  //                   .catch(function(err) {
-  //                     return handleError(res, err);
-  //                   });
-  //               });
-  //           }
-  //         });
-  //       break;
-  //     default:
-  //       return handleError(res, new Error('Room type unsupported'));
-  //   }
-  //
-  //
-  // } else if (req.body.ChatRoomId) {
-  //
-  //   ChatMessage
-  //     .create(_.merge({
-  //       userId: req.user.id,
-  //       email: req.user.email,
-  //       fullname: req.user.fullname
-  //     }, req.body))
-  //     .then(function(chatMessage) {
-  //       return res.status(201).send(chatMessage);
-  //     })
-  //     .catch(function(err) {
-  //       return handleError(res, err);
-  //     });
-  // } else {
-  //   return handleError(res, new Error('Select ChatRoomId or to'));
-  // }
-  ChatMessage
-    .create(_.merge(req.body, {
-      UserId: req.user.id
-    }))
-    .then(function (chatMessage) {
-      return res.status(201).send(chatMessage);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing chatMessage in the DB.
-exports.update = function (req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-
-  return ChatMessage
-    .findById(req.params.id)
-    .then(function (chatMessage) {
-      if (!chatMessage) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(chatMessage, req.body);
-      return updated.save();
-    })
-    .then(function (chatMessage) {
-      return res.status(200).send(chatMessage);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a chatMessage from the DB.
-exports.destroy = function (req, res) {
-  ChatMessage
-    .findById(req.params.id)
-    .then(function (chatMessage) {
-      if (!chatMessage) {
-        return res.sendStatus(404);
-      }
-      chatMessage.destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/chat_message/chat_message.socket.js b/server/api/chat_message/chat_message.socket.js
index dccab23..ea231f4 100644
--- a/server/api/chat_message/chat_message.socket.js
+++ b/server/api/chat_message/chat_message.socket.js
@@ -1,59 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var chat_message = require('../../models').ChatMessage;
-var _ = require('lodash');
-
-exports.register = function (socket) {
-  chat_message.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  chat_message.afterUpdate(function (doc) {
-    onSave(socket, doc);
-  });
-  chat_message.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  return doc
-    .getChatRoom()
-    .then(function (chatRoom) {
-      return [chatRoom
-        .getUsers({
-          attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal'],
-          raw: true
-        }), chatRoom
-        .getChatVisitor({
-          attributes: ['id', 'fullname', 'email'],
-          raw: true
-        })
-      ];
-    })
-    .spread(function (users, visitor) {
-      var sender = _.find(users, {
-        id: doc.UserId
-      });
-
-      users.forEach(function (user) {
-        // SOCKET FILTER
-        if (socket.userId == user.id && (sender || visitor)) {
-          socket.emit('chat_message:save', _.merge(doc.dataValues, {
-            User: sender, // TODO modify to sender
-            ChatVisitor: visitor // TODO modify to visitor
-          }));
-        }
-      });
-    })
-    .catch(function (err) {
-      console.error(err);
-    });
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('chat_message:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/chat_message/chat_message.spec.js b/server/api/chat_message/chat_message.spec.js
index f646838..d003cce 100644
--- a/server/api/chat_message/chat_message.spec.js
+++ b/server/api/chat_message/chat_message.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/chat/messages', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/chat/messages')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/chat_message/index.js b/server/api/chat_message/index.js
index 8de80e3..d1d36fc 100644
--- a/server/api/chat_message/index.js
+++ b/server/api/chat_message/index.js
@@ -1,16 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./chat_message.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', controller.update);
-// router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/chat_queue/chat_queue.controller.js b/server/api/chat_queue/chat_queue.controller.js
index a2eaab3..eb17d84 100644
--- a/server/api/chat_queue/chat_queue.controller.js
+++ b/server/api/chat_queue/chat_queue.controller.js
@@ -1,226 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var ChatQueue = require('../../models').ChatQueue;
-var UserHasChatQueue = require('../../models').UserHasChatQueue;
-
-// Get list of mailQueues
-exports.index = function (req, res) {
-
-  var attributes = ['description', 'name', 'timeout', 'strategy'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page,
-    include: [{
-      all: true
-    }]
-  };
-
-  _.forIn(req.query, function (value, key) {
-    switch (key) {
-    case 'per_page':
-    case 'page':
-      break;
-    case 'sort_by':
-      query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-      break;
-    case 'sort_order':
-      break;
-    case '$':
-      query.where.$or = [];
-      attributes.forEach(function (attribute) {
-        var tmp = {};
-        tmp[attribute] = {
-          $like: '%' + value + '%'
-        };
-
-        query.where.$or.push(tmp);
-      });
-      break;
-    default:
-      query.where[key] = {
-        $like: {}
-      };
-      query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  ChatQueue
-    .findAndCountAll(query)
-    .then(function (result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get list of my chat_rooms
-exports.me = function (req, res, next) {
-  UserHasChatQueue
-    .findAll({
-      where: {
-        UserId: req.user.id
-      }
-    })
-    .then(function (userHasChatQueues) {
-      return res.status(200).send(userHasChatQueues);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single chat_queue
-exports.show = function (req, res) {
-  ChatQueue
-    .findById(req.params.id)
-    .then(function (chat_queue) {
-      if (!chat_queue) {
-        return res.sendStatus(404);
-      }
-      return res.send(chat_queue);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new chat_queue in the DB.
-exports.create = function (req, res) {
-  ChatQueue
-    .create(req.body)
-    .then(function (chat_queue) {
-      return res.status(201).send(chat_queue);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing chat_queue in the DB.
-exports.update = function (req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ChatQueue
-    .findById(req.params.id)
-    .then(function (chat_queue) {
-      if (!chat_queue) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(chat_queue, req.body);
-      updated.save()
-        .then(function () {
-          return res.status(200).send(chat_queue);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing user_has_chatQueue in the DB.
-exports.addAgents = function (req, res, next) {
-  return ChatQueue
-    .findById(req.params.id)
-    .then(function (chatQueue) {
-      if (chatQueue) {
-        return chatQueue
-          .addUsers(req.body.agents, {
-            individualHooks: true
-          });
-      } else {
-        throw new Error('No mail queue found');
-      }
-    })
-    .then(function () {
-      return res.sendStatus(200);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-exports.removeAgents = function (req, res, next) {
-  return ChatQueue
-    .findById(req.params.id)
-    .then(function (chatQueue) {
-      if (chatQueue) {
-        return chatQueue
-          .removeUsers(req.body.agents, {
-            individualHooks: true
-          });
-      } else {
-        throw new Error('no mail queue found');
-      }
-    })
-    .then(function () {
-      return res.sendStatus(200);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Deletes a chat_queue from the DB.
-exports.destroy = function (req, res) {
-  ChatQueue
-    .findById(req.params.id)
-    .then(function (chat_queue) {
-      if (!chat_queue) {
-        return res.sendStatus(404);
-      }
-      chat_queue.destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function (req, res) {
-  ChatQueue
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function () {
-      return res.sendStatus(204);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/chat_queue/chat_queue.socket.js b/server/api/chat_queue/chat_queue.socket.js
index 2e7f5d4..ed889f6 100644
--- a/server/api/chat_queue/chat_queue.socket.js
+++ b/server/api/chat_queue/chat_queue.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var chatQueue = require('../../models').ChatQueue;
-
-exports.register = function (socket) {
-  chatQueue.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  chatQueue.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('chat_queue:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('chat_queue:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/chat_queue/chat_queue.spec.js b/server/api/chat_queue/chat_queue.spec.js
index 172be01..b0b5a91 100644
--- a/server/api/chat_queue/chat_queue.spec.js
+++ b/server/api/chat_queue/chat_queue.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/chat/queues', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/chat/queues')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/chat_queue/index.js b/server/api/chat_queue/index.js
index ab30e8c..da3c642 100644
--- a/server/api/chat_queue/index.js
+++ b/server/api/chat_queue/index.js
@@ -1,20 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./chat_queue.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/me', auth.isAuthenticated(), controller.me);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.post('/:id/agents', controller.addAgents);
-router.put('/:id', controller.update);
-router.put('/:id/agents', controller.removeAgents);
-router.patch('/:id', controller.update);
-router.delete('/', controller.bulkDestroy);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/chat_room/chat_room.controller.js b/server/api/chat_room/chat_room.controller.js
index e423038..589c37d 100644
--- a/server/api/chat_room/chat_room.controller.js
+++ b/server/api/chat_room/chat_room.controller.js
@@ -1,455 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var md5 = require('md5');
-var moment = require('moment');
-
-var User = require('../../models').User;
-var ChatRoom = require('../../models').ChatRoom;
-var ChatMessage = require('../../models').ChatMessage;
-var ChatVisitor = require('../../models').ChatVisitor;
-var UserHasChatRoom = require('../../models').UserHasChatRoom;
-
-
-// Get list of chat_rooms
-exports.index = function (req, res) {
-  return ChatRoom
-    .findAll({
-      include: [User, ChatMessage, ChatVisitor]
-    })
-    .then(function (chat_rooms) {
-      return res.status(200).send(chat_rooms);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get list of my chat_rooms
-exports.me = function (req, res) {
-  return User
-    .findById(req.user.id)
-    .then(function (user) {
-      return user
-        .getChatRooms({
-          include: [{
-            model: ChatVisitor,
-            attributes: ['id', 'fullname', 'email']
-          }, {
-            model: User,
-            attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal']
-          }]
-        });
-    })
-    .then(function (chatRooms) {
-      if (!chatRooms) {
-        return res.sendStatus(404);
-      }
-      return res.send(chatRooms);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single chatRoom
-exports.show = function (req, res) {
-  return ChatRoom
-    .findById(req.params.id, {
-      include: [{
-        model: ChatMessage,
-        include: [{
-          model: ChatVisitor,
-          attributes: ['id', 'email', 'fullname']
-        }, {
-          model: User,
-          attributes: ['id', 'email', 'name', 'fullname']
-        }]
-      }, {
-        model: User,
-        attributes: ['id', 'email', 'name', 'fullname']
-      }]
-    })
-    .then(function (chatRoom) {
-      if (!chatRoom) {
-        return res.sendStatus(404);
-      }
-      return res.send(chatRoom);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single chatRoom by users
-exports.getRoomByUsers = function (req, res, next) {
-
-  var _chatRoom;
-
-  return ChatRoom
-    .findOrCreate({
-      where: {
-        token: md5(JSON.stringify(req.query.users.sort())).toString('base64')
-      },
-      defaults: {
-        type: 'internal',
-        token: md5(JSON.stringify(req.query.users.sort())).toString('base64'),
-        status: 'open'
-      },
-      include: [{
-        model: ChatMessage,
-        include: [{
-          model: ChatVisitor,
-          attributes: ['id', 'email', 'fullname']
-        }, {
-          model: User,
-          attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal']
-        }]
-      }, {
-        model: User,
-        attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal']
-      }]
-    })
-    .spread(function (chatRoom, created) {
-      _chatRoom = chatRoom;
-      // _chatRoom.dataValues.ChatMessages = [];
-      if (created) {
-        return _chatRoom
-          .setUsers(req.query.users);
-      } else {
-        return;
-      }
-    })
-    .then(function () {
-      return _chatRoom
-        .getUsers();
-    })
-    .then(function (users) {
-      return res.status(200).send(_.merge(_chatRoom.dataValues, {
-        Users: users
-      }));
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single chatRoom
-exports.getRoomByType = function (req, res) {
-  User
-    .findById(req.user.id)
-    .then(function (user) {
-      user
-        .getChatRooms({
-          where: {
-            type: req.params.type
-          },
-          include: [{
-            model: ChatVisitor,
-            attributes: ['id', 'fullname', 'email']
-          }]
-        })
-        .then(function (chatRooms) {
-          if (!chatRooms) {
-            return res.sendStatus(404);
-          }
-          return res.send(chatRooms);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single chatRoom
-exports.getRoomGroups = function (req, res) {
-  User
-    .findById(req.user.id)
-    .then(function (user) {
-      user
-        .getChatRooms({
-          include: [{
-            model: ChatVisitor,
-            attributes: ['id', 'fullname', 'email']
-          }, {
-            model: User,
-            attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal']
-          }]
-        })
-        .then(function (chatRooms) {
-          if (!chatRooms) {
-            return res.sendStatus(404);
-          }
-          return res.send(chatRooms);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new chatRoom in the DB.
-exports.create = function (req, res) {
-  // if (req.body.to) {
-  //
-  //   var token;
-  //   var participants = {
-  //     users: {
-  //       ids: []
-  //     },
-  //     visitor: {}
-  //   };
-  //
-  //   switch (req.body.type) {
-  //     case 'internal':
-  //
-  //       if (!req.body.to.isArray) {
-  //         req.body.to = [parseInt(req.body.to, 10)];
-  //       }
-  //
-  //       participants.users.ids = req.body.to;
-  //
-  //       if (!_.contains(req.body.to, req.user.id)) {
-  //         participants.users.ids.push(req.user.id);
-  //       }
-  //
-  //       participants.users.ids.sort();
-  //
-  //       token = md5(JSON.stringify(participants)).toString(
-  //         'base64');
-  //
-  //       participants.users.fullnames = [];
-  //
-  //       User
-  //         .findAll({
-  //           where: {
-  //             id: {
-  //               $in: req.body.to
-  //             }
-  //           },
-  //           attributes: ['id', 'fullname']
-  //         })
-  //         .then(function(users) {
-  //
-  //           _.sortBy(users, 'id').forEach(function(item, index) {
-  //             participants.users.fullnames.push(item.fullname);
-  //           });
-  //
-  //           ChatRoom
-  //             .findOrCreate({
-  //               where: {
-  //                 token: token
-  //               },
-  //               defaults: _.merge({
-  //                 token: token,
-  //                 participants: JSON.stringify(participants)
-  //               }, req.body),
-  //               include: [{
-  //                 model: ChatMessage
-  //               }]
-  //             })
-  //             .spread(function(chatRoom, created) {
-  //
-  //               if (created) {
-  //                 chatRoom
-  //                   .setUsers(participants.users.ids)
-  //                   .then(function() {
-  //                     return res.status(201).send(chatRoom);
-  //                   })
-  //                   .catch(function(err) {
-  //                     return handleError(res, err);
-  //                   });
-  //               } else {
-  //                 return res.status(201).send(chatRoom);
-  //               }
-  //
-  //             })
-  //             .catch(function(err) {
-  //               return handleError(res, err);
-  //             });
-  //         })
-  //         .catch(function(err) {
-  //           return handleError(res, err);
-  //         });
-  //
-  //       break;
-  //     case 'external':
-  //
-  //       participants.visitor.id = req.body.to;
-  //       participants.users.ids.push(req.user.id);
-  //       participants.users.ids.sort();
-  //
-  //       token = md5(JSON.stringify(participants)).toString('base64');
-  //
-  //       participants.users.fullnames = [req.user.fullname];
-  //
-  //       ChatVisitor
-  //         .findById(req.body.to, {
-  //           attributes: ['id', 'fullname', 'email', 'referer']
-  //         })
-  //         .then(function(chatVisitor) {
-  //           participants.visitor.fullname = chatVisitor.fullname;
-  //           participants.visitor.referer = chatVisitor.referer;
-  //           participants.visitor.email = chatVisitor.email;
-  //
-  //           ChatRoom
-  //             .findOrCreate({
-  //               where: {
-  //                 token: token
-  //               },
-  //               defaults: _.merge({
-  //                 token: token,
-  //                 participants: JSON.stringify(participants)
-  //               }, req.body),
-  //               include: [{
-  //                 model: ChatMessage
-  //               }, {
-  //                 model: ChatVisitor
-  //               }, {
-  //                 model: User,
-  //               }]
-  //             })
-  //             .spread(function(chatRoom, created) {
-  //               if (created) {
-  //
-  //                 chatRoom
-  //                   .setUsers(participants.users.ids, {
-  //                     individualHooks: true
-  //                   })
-  //                   .then(function() {
-  //                     chatRoom
-  //                       .setChatVisitor(participants.visitor.id)
-  //                       .then(function() {
-  //                         return res.status(201).send(chatRoom);
-  //                       })
-  //                       .catch(function(err) {
-  //                         return handleError(res, err);
-  //                       });
-  //                   })
-  //                   .catch(function(err) {
-  //                     return handleError(res, err);
-  //                   });
-  //               } else {
-  //                 return res.status(201).send(chatRoom);
-  //               }
-  //
-  //             })
-  //             .catch(function(err) {
-  //               return handleError(res, err);
-  //             });
-  //         })
-  //         .catch(function(err) {
-  //           return handleError(res, err);
-  //         });
-  //
-  //       break;
-  //     default:
-  //   }
-  // } else {
-  //   return handleError(res, new Error('field "to" omitted'));
-  // }
-};
-
-// Updates an existing chatRoom in the DB.
-exports.update = function (req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-
-  ChatRoom
-    .findById(req.params.id)
-    .then(function (chatRoom) {
-      if (!chatRoom) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(chatRoom, req.body);
-      updated
-        .save()
-        .then(function () {
-          return res.status(200).send(chatRoom);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing chatRoom in the DB.
-exports.updateUsers = function (req, res) {
-  var _chatRoom;
-
-  if (req.body.id) {
-    delete req.body.id;
-  }
-
-  return ChatRoom
-    .findById(req.params.id)
-    .then(function (chatRoom) {
-      if (!chatRoom || !req.body.users) {
-        return res.sendStatus(404);
-      }
-      return chatRoom;
-    })
-    .then(function (chatRoom) {
-      return chatRoom
-        .update({
-          token: md5(JSON.stringify(req.body.users.sort())).toString('base64')
-        });
-    })
-    .then(function (chatRoom) {
-      _chatRoom = chatRoom;
-      return chatRoom
-        .setUsers(req.body.users.sort(), {
-          individualHooks: true
-        });
-    })
-    .then(function () {
-      return _chatRoom
-        .getUsers();
-    })
-    .then(function (users) {
-      return res.status(200).send(_.merge(_chatRoom.dataValues, {
-        Users: users,
-        ChatMessages: []
-      }));
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a chatRoom from the DB.
-exports.destroy = function (req, res) {
-  ChatRoom
-    .findById(req.params.id)
-    .then(function (chatRoom) {
-      if (!chatRoom) {
-        return res.sendStatus(404);
-      }
-
-      chatRoom
-        .destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/chat_room/chat_room.socket.js b/server/api/chat_room/chat_room.socket.js
index 2f75a98..a8724a6 100644
--- a/server/api/chat_room/chat_room.socket.js
+++ b/server/api/chat_room/chat_room.socket.js
@@ -1,30 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var User = require('../../models').User;
-var ChatRoom = require('../../models').ChatRoom;
-var ChatMessage = require('../../models').ChatMessage;
-var ChatVisitor = require('../../models').ChatVisitor;
-
-exports.register = function (socket) {
-  ChatRoom.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  ChatRoom.afterUpdate(function (doc) {
-    onSave(socket, doc);
-  });
-  ChatRoom.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('chat_room:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('chat_room:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/chat_room/chat_room.spec.js b/server/api/chat_room/chat_room.spec.js
index c76c928..99b7d41 100644
--- a/server/api/chat_room/chat_room.spec.js
+++ b/server/api/chat_room/chat_room.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/chat/rooms', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/chat/rooms')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/chat_room/index.js b/server/api/chat_room/index.js
index 9c38043..6fb946b 100644
--- a/server/api/chat_room/index.js
+++ b/server/api/chat_room/index.js
@@ -1,20 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./chat_room.controller');
-var auth = require('../../auth/auth.service');
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/me', auth.isAuthenticated(), controller.me);
-router.get('/users', auth.isAuthenticated(), controller.getRoomByUsers);
-router.get('/groups', auth.isAuthenticated(), controller.getRoomGroups);
-router.get('/type/:type', auth.isAuthenticated(), controller.getRoomByType);
-router.get('/:id', controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', controller.update);
-router.put('/:id/users', controller.updateUsers);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/chat_visitor/chat_visitor.controller.js b/server/api/chat_visitor/chat_visitor.controller.js
index 4297f32..b3f60d7 100644
--- a/server/api/chat_visitor/chat_visitor.controller.js
+++ b/server/api/chat_visitor/chat_visitor.controller.js
@@ -1,94 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ChatVisitor = require('../../models').ChatVisitor;
-
-// Get list of chat_visitors
-exports.index = function(req, res) {
-  ChatVisitor
-    .findAll()
-    .then(function(chat_visitors) {
-      return res.status(200).send(chat_visitors);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single chat_visitor
-exports.show = function(req, res) {
-  ChatVisitor
-    .findById(req.params.id)
-    .then(function(chat_visitor) {
-      if (!chat_visitor) {
-        return res.sendStatus(404);
-      }
-      return res.send(chat_visitor);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new chat_visitor in the DB.
-exports.create = function(req, res) {
-
-  ChatVisitor
-    .create(req.body)
-    .then(function(chat_visitor) {
-      return res.status(201).send(chat_visitor);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing chat_visitor in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ChatVisitor
-    .findById(req.params.id)
-    .then(function(chat_visitor) {
-      if (!chat_visitor) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(chat_visitor, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(chat_visitor);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a chat_visitor from the DB.
-exports.destroy = function(req, res) {
-  ChatVisitor
-    .findById(req.params.id)
-    .then(function(chat_visitor) {
-      if (!chat_visitor) {
-        return res.sendStatus(404);
-      }
-      chat_visitor.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/chat_visitor/chat_visitor.socket.js b/server/api/chat_visitor/chat_visitor.socket.js
index a283bfc..0d91b98 100644
--- a/server/api/chat_visitor/chat_visitor.socket.js
+++ b/server/api/chat_visitor/chat_visitor.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var chat_visitor = require('../../models').ChatVisitor;
-
-exports.register = function(socket) {
-  chat_visitor.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  chat_visitor.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  chat_visitor.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('chat_visitor:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('chat_visitor:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/chat_visitor/chat_visitor.spec.js b/server/api/chat_visitor/chat_visitor.spec.js
index ff6cda5..85d5a86 100644
--- a/server/api/chat_visitor/chat_visitor.spec.js
+++ b/server/api/chat_visitor/chat_visitor.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/chat/visitors', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/chat/visitors')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/chat_visitor/index.js b/server/api/chat_visitor/index.js
index 4a30e42..89fe538 100644
--- a/server/api/chat_visitor/index.js
+++ b/server/api/chat_visitor/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./chat_visitor.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/chat_website/chat_website.controller.js b/server/api/chat_website/chat_website.controller.js
index b9339a4..820c4c5 100644
--- a/server/api/chat_website/chat_website.controller.js
+++ b/server/api/chat_website/chat_website.controller.js
@@ -1,269 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var async = require('async');
-var Mustache = require('mustache');
-
-var sequelize = require('../../models').sequelize;
-var ChatWebsite = require('../../models').ChatWebsite;
-var ChatApplication = require('../../models').ChatApplication;
-var snippet = require('../../components/xchatty').snippet;
-
-// Get list of chat_websites
-exports.index = function (req, res, next) {
-
-  var attributes = ['name', 'address', 'description', 'remote'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function (value, key) {
-    switch (key) {
-    case 'per_page':
-    case 'page':
-      break;
-    case 'sort_by':
-      query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-      break;
-    case 'sort_order':
-      break;
-    case '$':
-      query.where.$or = [];
-      attributes.forEach(function (attribute) {
-        var tmp = {};
-        tmp[attribute] = {
-          $like: '%' + value + '%'
-        };
-
-        query.where.$or.push(tmp);
-      });
-      break;
-    default:
-      query.where[key] = {
-        $like: {}
-      };
-      query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  ChatWebsite
-    .findAndCountAll(query)
-    .then(function (result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function (err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single chat_website
-exports.show = function (req, res) {
-  ChatWebsite
-    .findById(req.params.id)
-    .then(function (chat_website) {
-      if (!chat_website) {
-        return res.sendStatus(404);
-      }
-      return res.send(chat_website);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a snippet for chat_website
-exports.getSnippetCode = function (req, res) {
-  ChatWebsite
-    .findById(req.params.id)
-    .then(function (chat_website) {
-      var configSnippet = {
-        remote: chat_website.remote,
-        websiteId: req.params.id
-      };
-      var html = Mustache.render(snippet, configSnippet);
-      return res.send(html);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new chat_website in the DB.
-exports.create = function (req, res) {
-  ChatWebsite
-    .create(req.body)
-    .then(function (chat_website) {
-      return res.status(201).send(chat_website);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing chat_website in the DB.
-exports.update = function (req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-
-  return ChatWebsite
-    .findById(req.params.id)
-    .then(function (chat_website) {
-      if (!chat_website) {
-        return res.sendStatus(404);
-      }
-
-      return chat_website
-        .update(req.body)
-        .then(function (chat_website) {
-          return res.status(200).send(chat_website);
-        })
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a chat_website from the DB.
-exports.destroy = function (req, res) {
-  ChatWebsite
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function (chat_website) {
-      if (!chat_website) {
-        return res.sendStatus(404);
-      }
-      chat_website.destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Sort Mail Applications
-exports.sortApplications = function (req, res, next) {
-
-  ChatApplication
-    .findAll({
-      where: {
-        id: req.body.applications
-      }
-    })
-    .then(function (chatApplications) {
-      var tmpChatApplications = chatApplications;
-
-      async.waterfall([
-        function (callback) {
-          ChatApplication
-            .destroy({
-              where: {
-                id: req.body.applications
-              }
-            }).then(function () {
-              callback();
-            })
-            .catch(function (err) {
-              callback(err);
-            });
-        },
-        function (callback) {
-          var sortedApplications = [];
-          for (var i = 0; i < req.body.applications.length; i++) {
-            var tmpChatApplication = _.find(tmpChatApplications, {
-              'id': req.body.applications[i]
-            });
-            if (tmpChatApplication) {
-              tmpChatApplication.priority = i + 1;
-              sortedApplications.push(tmpChatApplication.dataValues);
-            }
-          }
-
-          ChatApplication
-            .bulkCreate(sortedApplications)
-            .then(function () {
-              callback();
-            })
-            .catch(function (err) {
-              callback(err);
-            });
-        },
-        function (callback) {
-          ChatApplication
-            .findAll({
-              where: {
-                id: req.body.applications
-              },
-              order: 'priority',
-              include: [{
-                all: true
-              }]
-            })
-            .then(function (chatApplications) {
-              callback(null, chatApplications);
-            })
-            .catch(function (err) {
-              callback(err);
-            });
-        }
-      ], function (err, result) {
-        if (err) {
-          return handleError(res, err);
-        } else {
-          return res.status(201).send(result);
-        }
-      });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function (req, res) {
-  ChatWebsite
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function () {
-      return res.sendStatus(204);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/chat_website/chat_website.socket.js b/server/api/chat_website/chat_website.socket.js
index 49f62d6..3d99fb0 100644
--- a/server/api/chat_website/chat_website.socket.js
+++ b/server/api/chat_website/chat_website.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var chat_website = require('../../models').ChatWebsite;
-
-exports.register = function(socket) {
-  chat_website.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  chat_website.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('chat_website:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('chat_website:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/chat_website/chat_website.spec.js b/server/api/chat_website/chat_website.spec.js
index 4fd8b11..6a615d9 100644
--- a/server/api/chat_website/chat_website.spec.js
+++ b/server/api/chat_website/chat_website.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/chat/websites', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/chat/websites')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/chat_website/index.js b/server/api/chat_website/index.js
index c175aaf..0c4ac2f 100644
--- a/server/api/chat_website/index.js
+++ b/server/api/chat_website/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./chat_website.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id/snippet', auth.isAuthenticated(), controller.getSnippetCode);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/:id/applications', auth.isAuthenticated(), controller.sortApplications);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/company/company.controller.js b/server/api/company/company.controller.js
index 0e92164..8db8898 100644
--- a/server/api/company/company.controller.js
+++ b/server/api/company/company.controller.js
@@ -1,209 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Company = require('../../models').Company;
-var util = require('util');
-
-// Get list of companies
-exports.index = function(req, res) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Company
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-exports.companyValidation = function(req, res) {
-  console.log(req.body);
-  Company
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(companies) {
-      if (!companies) {
-        return res.sendStatus(404);
-      }
-      return res.send(companies);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single company
-exports.show = function(req, res) {
-  Company
-    .findById(req.params.id)
-    .then(function(company) {
-      if (!company) {
-        return res.sendStatus(404);
-      }
-      return res.send(company);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new company in the DB.
-exports.create = function(req, res) {
-  Company
-    .create(req.body)
-    .then(function(company) {
-      return res.status(201).send(company);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing company in the DB.
-exports.update = function(req, res) {
-  Company
-    .findAll({
-      where: {
-        name: req.body.name,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function(companies) {
-      if (!companies) {
-        return res.sendStatus(404);
-      }
-      if (companies.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_COMPANY'
-        })
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      Company
-        .find({
-          where: {
-            id: req.params.id
-          }
-        })
-        .then(function(company) {
-          if (!company) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(company, req.body);
-          updated.save()
-            .then(function() {
-              return res.status(200).send(company);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a company from the DB.
-exports.destroy = function(req, res) {
-  Company
-    .findById(req.params.id)
-    .then(function(company) {
-      if (!company) {
-        return res.sendStatus(404);
-      }
-      company.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.bulkDestroy = function(req, res) {
-  Company
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/company/company.socket.js b/server/api/company/company.socket.js
index 850be4a..c031a51 100644
--- a/server/api/company/company.socket.js
+++ b/server/api/company/company.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Company = require('../../models').Company;
-
-exports.register = function(socket) {
-  Company.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Company.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('company:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('company:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/company/company.spec.js b/server/api/company/company.spec.js
index 37c8889..29acb95 100644
--- a/server/api/company/company.spec.js
+++ b/server/api/company/company.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/contactmanager/companies', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/contactmanager/companies')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/company/index.js b/server/api/company/index.js
index 734f562..a9a97cb 100644
--- a/server/api/company/index.js
+++ b/server/api/company/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./company.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.companyValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/contact/contact.controller.js b/server/api/contact/contact.controller.js
index 1948319..8779d75 100644
--- a/server/api/contact/contact.controller.js
+++ b/server/api/contact/contact.controller.js
@@ -1,85 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Contact = require('../../models').Contact;
-
-// Get list of contacts
-exports.index = function(req, res) {
-  Contact
-  .findAll()
-  .then(function (contacts) {
-    return res.status(200).send(contacts);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Get a single contact
-exports.show = function(req, res) {
-  Contact
-  .findById(req.params.id)
-  .then(function (contact) {
-    if(!contact) { return res.sendStatus(404); }
-    return res.send(contact);
-  })
-  .catch(function(err){
-    return handleError(res, err);
-  });
-};
-
-// Creates a new contact in the DB.
-exports.create = function(req, res) {
-  Contact
-  .create(req.body)
-  .then(function(contact) {
-    return res.status(201).send(contact);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Updates an existing contact in the DB.
-exports.update = function(req, res) {
-  if(req.body.id) { delete req.body.id; }
-  Contact
-  .findById(req.params.id)
-  .then(function (contact) {
-    if(!contact) { return res.sendStatus(404); }
-    var updated = _.merge(contact, req.body);
-    updated.save()
-    .then(function () {
-      return res.status(200).send(contact);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Deletes a contact from the DB.
-exports.destroy = function(req, res) {
-  Contact
-  .findById(req.params.id)
-  .then(function (contact) {
-    if(!contact) { return res.sendStatus(404); }
-    contact.destroy()
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/contact/contact.model.js b/server/api/contact/contact.model.js
index e3414e8..2d4c204 100644
--- a/server/api/contact/contact.model.js
+++ b/server/api/contact/contact.model.js
@@ -1,13 +1 @@
-'use strict';
-
-module.export = function(sequelize, DataTypes) {
-
-  var Contact = sequelize.define('Contact', {
-    name: String,
-    info: String,
-    active: Boolean
-  });
-
-  return Contact;
-
-};
+var _0xac1b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x64\x65\x66\x69\x6E\x65"];_0xac1b[0];module[_0xac1b[1]]=function(_0x4596x1,_0x4596x2){var _0x4596x3=_0x4596x1[_0xac1b[3]](_0xac1b[2],{name:String,info:String,active:Boolean});return _0x4596x3;};
\ No newline at end of file
diff --git a/server/api/contact/contact.socket.js b/server/api/contact/contact.socket.js
index 849726b..3a7a67d 100644
--- a/server/api/contact/contact.socket.js
+++ b/server/api/contact/contact.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var contact = require('../../models').Contact;
-
-exports.register = function(socket) {
-  contact.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  contact.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('contact:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('contact:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/contact/contact.spec.js b/server/api/contact/contact.spec.js
index a856862..f862c28 100644
--- a/server/api/contact/contact.spec.js
+++ b/server/api/contact/contact.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/contacts', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/contacts')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/contact/index.js b/server/api/contact/index.js
index 1b36b44..8f2e7ac 100644
--- a/server/api/contact/index.js
+++ b/server/api/contact/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./contact.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/contact_manager/contact_manager.controller.js b/server/api/contact_manager/contact_manager.controller.js
index 27e39f6..1a53bac 100644
--- a/server/api/contact_manager/contact_manager.controller.js
+++ b/server/api/contact_manager/contact_manager.controller.js
@@ -1,516 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Contact = require('../../models').Contact;
-var ContactPhone = require('../../models').ContactPhone;
-var ContactEmail = require('../../models').ContactEmail;
-var CustomField = require('../../models').CustomField;
-var ReportCall = require('../../models').ReportCall;
-var ReportCallHistory = require('../../models').history.ReportCallHistory;
-var ReportMailSession = require('../../models').ReportMailSession;
-var ReportMailSessionHistory = require('../../models').history.ReportMailSessionHistory;
-var Tag = require('../../models').Tag;
-var stream = require('stream');
-var sequelize = require('../../models').sequelize;
-var util = require('util');
-
-// Get list of contacts
-exports.index = function(req, res) {
-
-  var attributes = ['name', 'surname', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-
-  Contact
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single managed_contact
-exports.show = function(req, res) {
-  Contact
-    .findById(req.params.id, {
-      include: [{
-        model: ContactPhone,
-        as: 'Phones',
-        include: [{
-          model: ReportCall,
-          as: 'Inbounds',
-          include: [{
-            all: true
-          }]
-        }, {
-          model: ReportCall,
-          as: 'Outbounds',
-          include: [{
-            all: true
-          }]
-        }, {
-          model: ReportCallHistory,
-          as: 'HistoryInbounds',
-          include: [{
-            all: true
-          }]
-        }, {
-          model: ReportCallHistory,
-          as: 'HistoryOutbounds',
-          include: [{
-            all: true
-          }]
-        }]
-      }, {
-        model: ContactEmail,
-        as: 'Emails',
-        include: [{
-          model: ReportMailSession,
-          as: 'InboundMessages',
-          include: [{
-            all: true
-          }]
-        }, {
-          model: ReportMailSession,
-          as: 'OutboundMessages',
-          include: [{
-            all: true
-          }]
-        }, {
-          model: ReportMailSessionHistory,
-          as: 'HistoryInboundMessages',
-          include: [{
-            all: true
-          }]
-        }, {
-          model: ReportMailSessionHistory,
-          as: 'HistoryOutboundMessages',
-          include: [{
-            all: true
-          }]
-        }]
-      }, {
-        model: CustomField,
-        as: 'CustomFields'
-      }]
-    })
-    .then(function(managed_contact) {
-      if (!managed_contact) {
-        return res.sendStatus(404);
-      }
-      return res.send(managed_contact);
-    })
-    .catch(function(err) {
-      console.log(err);
-      return handleError(res, err);
-    });
-};
-
-exports.getHistory = function(req, res) {
-
-};
-
-// validate contact uniqueness
-exports.contactValidation = function(req, res) {
-  Contact.findAll({
-      where: {
-        $or: {
-          '$Phones.phone$': req.body.phones,
-          '$Emails.email$': req.body.emails
-        }
-      },
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(contacts) {
-      console.log(contacts);
-      return res.status(200).send(contacts);
-    })
-    .catch(function(err) {
-      console.log(err);
-      return handleError(res, err);
-    });
-};
-
-// Creates a new managed_contact in the DB.
-exports.create = function(req, res, next) {
-  var newPhones = [],
-    newEmails = [],
-    newCustomFields = {};
-  Tag.findAll()
-    .then(function(tags) {
-      var newTags = [];
-      var tagList = _.pluck(_.pluck(tags, 'dataValues'), 'name');
-      if (req.body.tags) {
-        var contactTags = req.body.tags.split(',');
-        contactTags.forEach(function(elem) {
-          if (!_.includes(tags, elem)) {
-            newTags.push({
-              name: elem
-            });
-          }
-        });
-        if (newTags.length) {
-          Tag.bulkCreate(newTags, {
-            individualHooks: true
-          });
-        }
-      }
-      req.body.UserId = req.user.id;
-      var phones = _.uniq(_.pluck(req.body.Phones, 'phone'));
-      var contactPhones = [];
-      phones.forEach(function(elem) {
-        contactPhones.push(ContactPhone.findOrCreate({
-          where: {
-            phone: elem
-          },
-          defaults: {
-            phone: elem
-          }
-        }));
-      });
-      return contactPhones;
-    })
-    .all()
-    .then(function(res) {
-      newPhones = _.map(res, function(elem) {
-        return elem[0];
-      });
-
-      var contactEmails = [];
-      var emails = _.uniq(_.pluck(req.body.Emails, 'email'));
-      emails.forEach(function(elem) {
-        contactEmails.push(ContactEmail.findOrCreate({
-          where: {
-            email: elem
-          },
-          defaults: {
-            email: elem
-          }
-        }));
-      });
-      return contactEmails;
-    })
-    .all()
-    .then(function(res) {
-      newEmails = _.map(res, function(elem) {
-        return elem[0];
-      });
-      delete req.body.Phones;
-      delete req.body.Emails;
-      newCustomFields = _.clone(req.body.customFields);
-      delete req.body.customFields;
-
-      return Contact.create(req.body);
-    })
-    .then(function(contact) {
-      return [contact, contact.setPhones(newPhones)];
-    })
-    .spread(function(contact) {
-      return [contact, contact.setEmails(newEmails)];
-    })
-    .spread(function(contact) {
-      var customFieldsIds = _.keys(newCustomFields);
-      return [contact, CustomField.findAll({
-        where: {
-          id: customFieldsIds
-        }
-      })];
-    })
-    .spread(function(contact, customFields) {
-      customFields.forEach(function(elem) {
-        elem.ContactHasCustomField = {
-          value: newCustomFields[String(elem.id)]
-        }
-      });
-      return [contact, contact.setCustomFields(customFields)];
-    })
-    .spread(function(contact) {
-      return res.status(201).send(contact);
-    })
-    .catch(function(err) {
-      console.log(err);
-      return next(err);
-    });
-};
-
-// Updates an existing managed_contact in the DB.
-exports.update = function(req, res, next) {
-  var newPhones = [],
-    newEmails = [],
-    newCustomFields = {};
-  Tag.findAll()
-    .then(function(tags) {
-      var newTags = [];
-      var tagList = _.pluck(_.pluck(tags, 'dataValues'), 'name');
-      if (req.body.tags) {
-        var contactTags = req.body.tags.split(',');
-        contactTags.forEach(function(elem) {
-          if (!_.includes(tags, elem)) {
-            newTags.push({
-              name: elem
-            });
-          }
-        });
-        if (newTags.length) {
-          Tag.bulkCreate(newTags, {
-            individualHooks: true
-          });
-        }
-      }
-      var contactPhones = [];
-      var phones = _.uniq(_.pluck(req.body.Phones, 'phone'));
-      phones.forEach(function(elem) {
-        contactPhones.push(ContactPhone.findOrCreate({
-          where: {
-            phone: elem
-          },
-          defaults: {
-            phone: elem
-          }
-        }));
-      });
-      return contactPhones;
-    })
-    .all()
-    .then(function(res) {
-      newPhones = _.map(res, function(elem) {
-        return elem[0];
-      });
-
-      var contactEmails = [];
-      var emails = _.uniq(_.pluck(req.body.Emails, 'email'));
-      emails.forEach(function(elem) {
-        contactEmails.push(ContactEmail.findOrCreate({
-          where: {
-            email: elem
-          },
-          defaults: {
-            email: elem
-          }
-        }));
-      });
-      return contactEmails;
-    })
-    .all()
-    .then(function(res) {
-      newEmails = _.map(res, function(elem) {
-        return elem[0];
-      });
-      delete req.body.Phones;
-      delete req.body.Emails;
-      newCustomFields = _.clone(req.body.customFields);
-      delete req.body.customFields;
-      delete req.body.CustomFields;
-      var updateId = req.body.id;
-      delete req.body.id;
-
-      return Contact.findById(updateId);
-    })
-    .then(function(contact) {
-      return [contact, contact.setPhones(newPhones)];
-    })
-    .spread(function(contact) {
-      return [contact, contact.setEmails(newEmails)];
-    })
-    .spread(function(contact) {
-      var customFieldsIds = _.keys(newCustomFields);
-      return [contact, CustomField.findAll({
-        where: {
-          id: customFieldsIds
-        }
-      })];
-    })
-    .spread(function(contact, customFields) {
-      customFields.forEach(function(elem) {
-        elem.ContactHasCustomField = {
-          value: newCustomFields[String(elem.id)]
-        }
-      });
-      return [contact, contact.setCustomFields(customFields)];
-    })
-    .spread(function(contact) {
-      return contact.updateAttributes(req.body)
-    })
-    .then(function(contact) {
-      return res.status(200).send(contact);
-    })
-    .catch(function(err) {
-      console.log(err);
-      return handleError(res, err);
-    });
-};
-
-// // Join contacts info in the DB.
-// exports.joinContacts = function(req, res, next) {
-//   if (req.body.tags) {
-//     Tag.findAll()
-//       .then(function(tags) {
-//         var newTags = [];
-//         var tagList = _.pluck(_.pluck(tags, 'dataValues'), 'name');
-//         var contactTags = req.body.tags.split(',');
-//         contactTags.forEach(function(elem) {
-//           if (!_.includes(tags, elem)) {
-//             newTags.push({
-//               name: elem
-//             });
-//           }
-//         });
-//         if (newTags.length) {
-//           Tag.bulkCreate(newTags, {
-//             individualHooks: true
-//           });
-//         }
-//       })
-//       .catch(function(err) {
-//         return handleError(res, err);
-//       });
-//   }
-//   var updateId = req.body.id;
-//   delete req.body.id;
-//   var phones = _.map(req.body.Phones, function(elem) {
-//     return {
-//       phone: elem.phone,
-//       ContactId: updateId
-//     };
-//   });
-//   var emails = _.map(req.body.Emails, function(elem) {
-//     return {
-//       email: elem.email,
-//       ContactId: updateId
-//     };
-//   });
-//   delete req.body.Phones;
-//   delete req.body.Emails;
-//   return sequelize.transaction(function(t) {
-//       return Contact.update(req.body, {
-//           where: {
-//             id: updateId
-//           }
-//         }, {
-//           transaction: t,
-//           include: [{
-//             all: true
-//           }]
-//         })
-//         .then(function(contact) {
-//           return ContactPhone
-//             .bulkCreate(phones, {
-//               transaction: t
-//             })
-//             .then(function() {
-//               return ContactEmail
-//                 .bulkCreate(emails, {
-//                   transaction: t
-//                 })
-//                 .then(function() {
-//                   return Contact.findById(updateId, {
-//                       transaction: t
-//                     })
-//                     .then(function(contact) {
-//                       return res.status(201).send(contact);
-//                     })
-//                 })
-//             })
-//         })
-//     })
-//     .catch(function(err) {
-//       console.log(err);
-//       return next(err);
-//     });
-// };
-
-// Deletes a managed_contact from the DB.
-exports.destroy = function(req, res) {
-  Contact
-    .findById(req.params.id)
-    .then(function(managed_contact) {
-      if (!managed_contact) {
-        return res.sendStatus(404);
-      }
-      managed_contact.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a managed_contact from the DB.
-exports.bulkDestroy = function(req, res) {
-  Contact
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/contact_manager/contact_manager.socket.js b/server/api/contact_manager/contact_manager.socket.js
index addfca0..073990e 100644
--- a/server/api/contact_manager/contact_manager.socket.js
+++ b/server/api/contact_manager/contact_manager.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Contact = require('../../models').Contact;
-
-exports.register = function(socket) {
-  Contact.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Contact.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('contact_manager:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('contact_manager:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/contact_manager/contact_manager.spec.js b/server/api/contact_manager/contact_manager.spec.js
index e751625..0ce96de 100644
--- a/server/api/contact_manager/contact_manager.spec.js
+++ b/server/api/contact_manager/contact_manager.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/contactmanager', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/contactmanager')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/contact_manager/index.js b/server/api/contact_manager/index.js
index cc44c15..8785590 100644
--- a/server/api/contact_manager/index.js
+++ b/server/api/contact_manager/index.js
@@ -1,20 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./contact_manager.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id/history', auth.isAuthenticated(), controller.getHistory);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.contactValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-// router.put('/join/:id', auth.isAuthenticated(), controller.joinContacts);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/custom_field/custom_field.controller.js b/server/api/custom_field/custom_field.controller.js
index ae5b52d..0f749cb 100644
--- a/server/api/custom_field/custom_field.controller.js
+++ b/server/api/custom_field/custom_field.controller.js
@@ -1,223 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var CustomField = require('../../models').CustomField;
-var util = require('util');
-
-// Get list of customFields
-exports.index = function(req, res) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {
-      active: true
-    },
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  CustomField
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get all custom_fields
-exports.getAll = function(req, res) {
-  CustomField
-    .findAll()
-    .then(function(customFields) {
-      return res.status(200).send(customFields);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.customFieldValidation = function(req, res) {
-  console.log(req.body);
-  CustomField
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(customFields) {
-      if (!customFields) {
-        return res.sendStatus(404);
-      }
-      return res.send(customFields);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single customField
-exports.show = function(req, res) {
-  CustomField
-    .findById(req.params.id)
-    .then(function(customField) {
-      if (!customField) {
-        return res.sendStatus(404);
-      }
-      return res.send(customField);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new customField in the DB.
-exports.create = function(req, res) {
-  CustomField
-    .create(req.body)
-    .then(function(customField) {
-      return res.status(201).send(customField);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing customField in the DB.
-exports.update = function(req, res) {
-  CustomField
-    .findAll({
-      where: {
-        name: req.body.name,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function(customFields) {
-      if (!customFields) {
-        return res.sendStatus(404);
-      }
-      if (customFields.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_CUSTOM_FIELD'
-        })
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      CustomField
-        .findById(req.params.id)
-        .then(function(customField) {
-          if (!customField) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(customField, req.body);
-          updated.save()
-            .then(function() {
-              return res.status(200).send(customField);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a customField from the DB.
-exports.deactivate = function(req, res) {
-  CustomField
-    .findById(req.params.id)
-    .then(function(customField) {
-      if (!customField) {
-        return res.sendStatus(404);
-      }
-      customField.update({
-          active: false
-        })
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.bulkDeactivate = function(req, res) {
-  CustomField
-    .update({
-      active: false
-    }, {
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/custom_field/custom_field.socket.js b/server/api/custom_field/custom_field.socket.js
index f607668..eea0295 100644
--- a/server/api/custom_field/custom_field.socket.js
+++ b/server/api/custom_field/custom_field.socket.js
@@ -1,29 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var CustomField = require('../../models').CustomField;
-
-exports.register = function(socket) {
-  CustomField.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  CustomField.afterUpdate(function(doc) {
-    if (!doc.active) {
-      onRemove(socket, doc);
-    }
-  });
-  CustomField.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('custom_field:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('custom_field:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/custom_field/custom_field.spec.js b/server/api/custom_field/custom_field.spec.js
index 852dba1..6777daa 100644
--- a/server/api/custom_field/custom_field.spec.js
+++ b/server/api/custom_field/custom_field.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/contactmanager/customfields', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/contactmanager/customfields')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/custom_field/index.js b/server/api/custom_field/index.js
index dd4afaf..aecbb40 100644
--- a/server/api/custom_field/index.js
+++ b/server/api/custom_field/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./custom_field.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/all', auth.isAuthenticated(), controller.getAll);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.customFieldValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDeactivate);
-router.delete('/:id', auth.isAuthenticated(), controller.deactivate);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/custom_report/custom_report.controller.js b/server/api/custom_report/custom_report.controller.js
index abb7d2b..821a4a4 100644
--- a/server/api/custom_report/custom_report.controller.js
+++ b/server/api/custom_report/custom_report.controller.js
@@ -1,160 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var CustomReport = require('../../models').CustomReport;
-var ReportTree = require('../../models').ReportTree;
-
-
-// Get list of custom reports
-exports.index = function(req, res, next) {
-
-  var attributes = ['name', 'description', 'parent'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      case 'role':
-        query.where.role = {
-          $or: value.split(/[\s,]+/)
-        };
-        break;
-      case 'clientQuery':
-        var params = JSON.parse(value);
-        _.forOwn(params, function(pValue, pKey) {
-          query.where[pKey] = pValue;
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  CustomReport
-    .findAndCountAll(query)
-    .then(function(result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single report
-exports.show = function(req, res) {
-  CustomReport
-    .findById(req.params.id)
-    .then(function(report) {
-      if (!report) {
-        return res.sendStatus(404);
-      }
-      return res.send(report);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new report in the DB.
-exports.create = function(req, res) {
-  CustomReport
-    .create(req.body)
-    .then(function(report) {
-      return res.status(201).send(report);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing report in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  CustomReport
-    .findById(req.params.id)
-    .then(function(report) {
-      if (!report) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(report, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(report);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a report from the DB.
-exports.destroy = function(req, res) {
-  CustomReport
-    .findById(req.params.id)
-    .then(function(report) {
-      if (!report) {
-        return res.sendStatus(404);
-      }
-      report.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/custom_report/custom_report.socket.js b/server/api/custom_report/custom_report.socket.js
index 07bf827..099f03b 100644
--- a/server/api/custom_report/custom_report.socket.js
+++ b/server/api/custom_report/custom_report.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var CustomReport = require('../../models').CustomReport;
-
-exports.register = function(socket) {
-  CustomReport.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  CustomReport.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('custom_report:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('custom_report:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/custom_report/custom_report.spec.js b/server/api/custom_report/custom_report.spec.js
index 905f802..52136db 100644
--- a/server/api/custom_report/custom_report.spec.js
+++ b/server/api/custom_report/custom_report.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/analytics/reports/custom', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/analytic/reports/custom')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/custom_report/index.js b/server/api/custom_report/index.js
index 403aa5c..b26f0cd 100644
--- a/server/api/custom_report/index.js
+++ b/server/api/custom_report/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./custom_report.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/dashboard/dashboard.controller.js b/server/api/dashboard/dashboard.controller.js
index 986e3f4..6d9cb67 100644
--- a/server/api/dashboard/dashboard.controller.js
+++ b/server/api/dashboard/dashboard.controller.js
@@ -1,178 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var Dashboard = require('../../models').Dashboard;
-
-// Get list of dashboards
-exports.index = function(req, res) {
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Dashboard
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      return res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single dashboard
-exports.all = function(req, res) {
-  Dashboard
-    .findAll()
-    .then(function(dashboards) {
-      if (!dashboards) {
-        return res.sendStatus(404);
-      }
-      return res.status(200).send(dashboards);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single dashboard
-exports.show = function(req, res) {
-  Dashboard
-    .findById(req.params.id)
-    .then(function(dashboard) {
-      if (!dashboard) {
-        return res.sendStatus(404);
-      }
-      return res.send(dashboard);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new dashboard in the DB.
-exports.create = function(req, res) {
-  Dashboard
-    .create(req.body)
-    .then(function(dashboard) {
-      return res.status(201).send(dashboard);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing dashboard in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Dashboard
-    .findById(req.params.id)
-    .then(function(dashboard) {
-      if (!dashboard) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(dashboard, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(dashboard);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a dashboard from the DB.
-exports.destroy = function(req, res) {
-  Dashboard
-    .findById(req.params.id)
-    .then(function(dashboard) {
-      if (!dashboard) {
-        return res.sendStatus(404);
-      }
-      dashboard.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.bulkDestroy = function(req, res) {
-  Dashboard
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/dashboard/dashboard.socket.js b/server/api/dashboard/dashboard.socket.js
index 9bf2215..3aea1c1 100644
--- a/server/api/dashboard/dashboard.socket.js
+++ b/server/api/dashboard/dashboard.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Dashboard = require('../../models').Dashboard;
-
-exports.register = function(socket) {
-  Dashboard.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Dashboard.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  Dashboard.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('dashboard:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('dashboard:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/dashboard/dashboard.spec.js b/server/api/dashboard/dashboard.spec.js
index 4784e74..b8352f3 100644
--- a/server/api/dashboard/dashboard.spec.js
+++ b/server/api/dashboard/dashboard.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/dashboards', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/dashboards')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/dashboard/index.js b/server/api/dashboard/index.js
index 6f966a0..bb5794b 100644
--- a/server/api/dashboard/index.js
+++ b/server/api/dashboard/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./dashboard.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/all', auth.isAuthenticated(), controller.all);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/default_report/default_report.controller.js b/server/api/default_report/default_report.controller.js
index faa5dc7..514d126 100644
--- a/server/api/default_report/default_report.controller.js
+++ b/server/api/default_report/default_report.controller.js
@@ -1,159 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var DefaultReport = require('../../models').DefaultReport;
-
-// Get list of default reports
-exports.index = function(req, res, next) {
-
-  var attributes = ['name', 'description', 'parent'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      case 'role':
-        query.where.role = {
-          $or: value.split(/[\s,]+/)
-        };
-        break;
-      case 'clientQuery':
-        var params = JSON.parse(value);
-        _.forOwn(params, function(pValue, pKey) {
-          query.where[pKey] = pValue;
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  DefaultReport
-    .findAndCountAll(query)
-    .then(function(result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-
-// Get a single report
-exports.show = function(req, res) {
-  DefaultReport
-    .findById(req.params.id)
-    .then(function(report) {
-      if (!report) {
-        return res.sendStatus(404);
-      }
-      return res.send(report);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new report in the DB.
-exports.create = function(req, res) {
-  DefaultReport
-    .create(req.body)
-    .then(function(report) {
-      return res.status(201).send(report);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing report in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  DefaultReport
-    .findById(req.params.id)
-    .then(function(report) {
-      if (!report) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(report, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(report);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a report from the DB.
-exports.destroy = function(req, res) {
-  DefaultReport
-    .findById(req.params.id)
-    .then(function(report) {
-      if (!report) {
-        return res.sendStatus(404);
-      }
-      report.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/default_report/default_report.socket.js b/server/api/default_report/default_report.socket.js
index 2acd563..aee73fa 100644
--- a/server/api/default_report/default_report.socket.js
+++ b/server/api/default_report/default_report.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var DefaultReport = require('../../models').DefaultReport;
-
-exports.register = function(socket) {
-  DefaultReport.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  DefaultReport.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('default_report:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('default_report:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/default_report/default_report.spec.js b/server/api/default_report/default_report.spec.js
index 2a6c81d..6f840ae 100644
--- a/server/api/default_report/default_report.spec.js
+++ b/server/api/default_report/default_report.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/analytics/reports/default', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/analytic/reports/default')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/default_report/index.js b/server/api/default_report/index.js
index 6bf1130..be40605 100644
--- a/server/api/default_report/index.js
+++ b/server/api/default_report/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./default_report.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/desk_account/desk_account.controller.js b/server/api/desk_account/desk_account.controller.js
index 78e1902..9f59697 100644
--- a/server/api/desk_account/desk_account.controller.js
+++ b/server/api/desk_account/desk_account.controller.js
@@ -1,256 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var desk = require('desk.js');
-
-var DeskAccount = require('../../models').DeskAccount;
-
-// Get list of desk_accounts
-exports.index = function(req, res) {
-  var attributes = ['description', 'name', 'username', 'remoteUri'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  DeskAccount
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      return res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single desk_account
-exports.show = function(req, res) {
-  DeskAccount
-    .findById(req.params.id)
-    .then(function(desk_account) {
-      if (!desk_account) {
-        return res.sendStatus(404);
-      }
-      return res.send(desk_account);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new desk_account in the DB.
-exports.create = function(req, res, next) {
-  DeskAccount
-    .create(req.body)
-    .then(function(desk_account) {
-      return res.status(201).send(desk_account);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing desk_account in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  DeskAccount
-    .findById(req.params.id)
-    .then(function(desk_account) {
-      if (!desk_account) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(desk_account, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(desk_account);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a desk_account from the DB.
-exports.destroy = function(req, res) {
-  DeskAccount
-    .findById(req.params.id)
-    .then(function(desk_account) {
-      if (!desk_account) {
-        return res.sendStatus(404);
-      }
-      desk_account.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.checkAccount = function(req, res) {
-  DeskAccount
-    .findById(req.params.id)
-    .then(function(account) {
-      var desk_account = {
-        endpoint: stripTrailingSlash(account.remoteUri),
-        retry: false
-      };
-      if (account.authType === 'basic') {
-        desk_account.username = account.username;
-        desk_account.password = account.password;
-      } else if (account.authType === 'oauth') {
-        desk_account.consumerKey = account.consumerKey;
-        desk_account.consumerSecret = account.consumerSecret;
-        desk_account.token = account.token;
-        desk_account.tokenSecret = account.tokenSecret;
-      }
-      var client = desk.createClient(desk_account);
-      client.get('/api/v2/users/me', function(err, body, response) {
-        if (err) {
-          return handleError(res, err);
-        }
-        return res.sendStatus(200);
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.deskValidation = function(req, res) {
-  var where = {};
-  where[req.params.field] = req.body.value;
-  DeskAccount
-    .findAndCountAll({
-      where: where
-    })
-    .then(function(result) {
-      if (result.count) {
-        return res.status(200).send({
-          isValid: false,
-          value: req.body.value
-        });
-      }
-      return res.status(200).send({
-        isValid: true,
-        value: req.body.value
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.getFields = function(req, res) {
-  DeskAccount
-    .findById(req.params.id)
-    .then(function(account) {
-      var desk_account = {
-        endpoint: stripTrailingSlash(account.remoteUri),
-        retry: false
-      };
-      if (account.authType === 'basic') {
-        desk_account.username = account.username;
-        desk_account.password = account.password;
-      } else if (account.authType === 'oauth') {
-        desk_account.consumerKey = account.consumerKey;
-        desk_account.consumerSecret = account.consumerSecret;
-        desk_account.token = account.token;
-        desk_account.tokenSecret = account.tokenSecret;
-      }
-      var client = desk.createClient(desk_account);
-      client.get('/api/v2/custom_fields', function(err, body, response) {
-        if (err) {
-          return handleError(res, err);
-        }
-        return res.status(200).json(body._embedded.entries);
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-}
-
-exports.bulkDestroy = function(req, res) {
-  DeskAccount
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function stripTrailingSlash(str) {
-  if (str.substr(-1) === '/') {
-    return str.substr(0, str.length - 1);
-  }
-  return str;
-}
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/desk_account/desk_account.socket.js b/server/api/desk_account/desk_account.socket.js
index 3f7badd..ebffac8 100644
--- a/server/api/desk_account/desk_account.socket.js
+++ b/server/api/desk_account/desk_account.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var DeskAccount = require('../../models').DeskAccount;
-
-exports.register = function(socket) {
-  DeskAccount.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  DeskAccount.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('desk_account:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('desk_account:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/desk_account/desk_account.spec.js b/server/api/desk_account/desk_account.spec.js
index a56fc11..55bf6c8 100644
--- a/server/api/desk_account/desk_account.spec.js
+++ b/server/api/desk_account/desk_account.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/desk/accounts', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/desk/accounts')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/desk_account/index.js b/server/api/desk_account/index.js
index 4a593d0..e6bcc3a 100644
--- a/server/api/desk_account/index.js
+++ b/server/api/desk_account/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./desk_account.controller');
-var auth = require('../../auth/auth.service');
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount);
-router.get('/:id/fields', auth.isAuthenticated(), controller.getFields);
-router.post('/validate/:field', auth.isAuthenticated(), controller.deskValidation);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/desk_configuration/desk_configuration.controller.js b/server/api/desk_configuration/desk_configuration.controller.js
index 3824ca1..ee78167 100644
--- a/server/api/desk_configuration/desk_configuration.controller.js
+++ b/server/api/desk_configuration/desk_configuration.controller.js
@@ -1,145 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/desk/configurations              ->  index
- * POST    /api/desk/configurations              ->  create
- * GET     /api/desk/configurations/:id          ->  show
- * PUT     /api/desk/configurations/:id          ->  update
- * DELETE  /api/desk/configurations/:id          ->  destroy
- */
-
-'use strict';
-
-var _ = require('lodash');
-
-var DeskConfiguration = require('../../models').DeskConfiguration;
-var DeskField = require('../../models').DeskField;
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of DeskConfigurations
-exports.index = function(req, res) {
-  DeskConfiguration.findAll({
-      where: req.query
-    })
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Gets a single DeskConfiguration from the DB
-exports.show = function(req, res) {
-  DeskConfiguration.find({
-      where: {
-        id: req.params.id
-      },
-      include: [{
-        model: DeskField,
-        as: 'Subject'
-      }, {
-        model: DeskField,
-        as: 'Description'
-      }, {
-        model: DeskField,
-        as: 'Field'
-      }]
-    })
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new DeskConfiguration in the DB
-exports.create = function(req, res) {
-  DeskConfiguration.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing DeskConfiguration in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  DeskConfiguration.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a DeskConfiguration from the DB
-exports.destroy = function(req, res) {
-  DeskConfiguration.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
-
-exports.addConfigurationField = function(req, res, next) {
-  // console.log(req.params);
-  var deskConfiguration;
-  DeskConfiguration
-    .findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(desk_configuration) {
-      deskConfiguration = desk_configuration;
-      return DeskField.create(req.body)
-    })
-    .then(function(deskField) {
-      switch (req.params.type) {
-        case 'subject':
-          return [deskConfiguration.addSubject(deskField), deskField];
-        case 'description':
-          return [deskConfiguration.addDescription(deskField), deskField];
-        case 'field':
-          return [deskConfiguration.addField(deskField), deskField];
-      }
-    })
-    .spread(function(data, deskField) {
-      return res.status(201).json(deskField);
-    })
-    .catch(handleError(res));
-};
\ No newline at end of file
diff --git a/server/api/desk_configuration/desk_configuration.socket.js b/server/api/desk_configuration/desk_configuration.socket.js
index d26e4f6..96e1889 100644
--- a/server/api/desk_configuration/desk_configuration.socket.js
+++ b/server/api/desk_configuration/desk_configuration.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var DeskConfiguration = require('../../models').DeskConfiguration;
-
-exports.register = function(socket) {
-  DeskConfiguration.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  DeskConfiguration.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('desk_configuration:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('desk_configuration:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/desk_configuration/index.js b/server/api/desk_configuration/index.js
index 91adaf0..ddba6ef 100644
--- a/server/api/desk_configuration/index.js
+++ b/server/api/desk_configuration/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./desk_configuration.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/desk_configuration/index.spec.js b/server/api/desk_configuration/index.spec.js
index fd6b650..8d90113 100644
--- a/server/api/desk_configuration/index.spec.js
+++ b/server/api/desk_configuration/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var deskConfigurationCtrlStub = {
-  index: 'deskConfigurationCtrl.index',
-  show: 'deskConfigurationCtrl.show',
-  create: 'deskConfigurationCtrl.create',
-  update: 'deskConfigurationCtrl.update',
-  destroy: 'deskConfigurationCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var deskConfigurationIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './desk_configuration.controller': deskConfigurationCtrlStub
-});
-
-describe('DeskConfiguration API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(deskConfigurationIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/desk/configurations', function() {
-
-    it('should route to deskConfiguration.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'deskConfigurationCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/desk/configurations/:id', function() {
-
-    it('should route to deskConfiguration.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'deskConfigurationCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/desk/configurations', function() {
-
-    it('should route to deskConfiguration.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'deskConfigurationCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/desk/configurations/:id', function() {
-
-    it('should route to deskConfiguration.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'deskConfigurationCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/desk/configurations/:id', function() {
-
-    it('should route to deskConfiguration.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'deskConfigurationCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/desk/configurations/:id', function() {
-
-    it('should route to deskConfiguration.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'deskConfigurationCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/desk_field/desk_field.controller.js b/server/api/desk_field/desk_field.controller.js
index 6b39f83..03826f9 100644
--- a/server/api/desk_field/desk_field.controller.js
+++ b/server/api/desk_field/desk_field.controller.js
@@ -1,104 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/desk/fields              ->  index
- * POST    /api/desk/fields              ->  create
- * GET     /api/desk/fields/:id          ->  show
- * PUT     /api/desk/fields/:id          ->  update
- * DELETE  /api/desk/fields/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-
-var DeskField = require('../../models').DeskField;
-
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of DeskFields
-exports.index = function(req, res) {
-  DeskField.findAll()
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Gets a single DeskField from the DB
-exports.show = function(req, res) {
-  DeskField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new DeskField in the DB
-exports.create = function(req, res) {
-  DeskField.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing DeskField in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  DeskField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a DeskField from the DB
-exports.destroy = function(req, res) {
-  DeskField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
\ No newline at end of file
diff --git a/server/api/desk_field/desk_field.socket.js b/server/api/desk_field/desk_field.socket.js
index b01d8f1..bc1b8d3 100644
--- a/server/api/desk_field/desk_field.socket.js
+++ b/server/api/desk_field/desk_field.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var DeskField = require('../../models').DeskField;
-
-exports.register = function(socket) {
-  DeskField.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  DeskField.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('desk_field:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('desk_field:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/desk_field/index.js b/server/api/desk_field/index.js
index 266676c..de03319 100644
--- a/server/api/desk_field/index.js
+++ b/server/api/desk_field/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./desk_field.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/desk_field/index.spec.js b/server/api/desk_field/index.spec.js
index fef888c..ccf80fe 100644
--- a/server/api/desk_field/index.spec.js
+++ b/server/api/desk_field/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var deskFieldCtrlStub = {
-  index: 'deskFieldCtrl.index',
-  show: 'deskFieldCtrl.show',
-  create: 'deskFieldCtrl.create',
-  update: 'deskFieldCtrl.update',
-  destroy: 'deskFieldCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var deskFieldIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './desk_field.controller': deskFieldCtrlStub
-});
-
-describe('DeskField API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(deskFieldIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/desk/fields', function() {
-
-    it('should route to deskField.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'deskFieldCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/desk/fields/:id', function() {
-
-    it('should route to deskField.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'deskFieldCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/desk/fields', function() {
-
-    it('should route to deskField.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'deskFieldCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/desk/fields/:id', function() {
-
-    it('should route to deskField.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'deskFieldCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/desk/fields/:id', function() {
-
-    it('should route to deskField.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'deskFieldCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/desk/fields/:id', function() {
-
-    it('should route to deskField.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'deskFieldCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/event/event.controller.js b/server/api/event/event.controller.js
index 07c951f..fb38dc8 100644
--- a/server/api/event/event.controller.js
+++ b/server/api/event/event.controller.js
@@ -1,119 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Event = require('../../models').Event;
-
-// Get list of events
-exports.index = function(req, res) {
-  Event
-    .findAll({
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(events) {
-      return res.status(200).send(events);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single event
-exports.showByChannel = function(req, res) {
-  Event
-    .findAll({
-      where: {
-        channel: req.params.channel.toUpperCase()
-      },
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(event) {
-      if (!event) {
-        return res.sendStatus(404);
-      }
-      return res.send(event);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single event
-exports.show = function(req, res) {
-  Event
-    .findById(req.params.id)
-    .then(function(event) {
-      if (!event) {
-        return res.sendStatus(404);
-      }
-      return res.send(event);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new event in the DB.
-exports.create = function(req, res) {
-  Event
-    .create(req.body)
-    .then(function(event) {
-      return res.status(201).send(event);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing event in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Event
-    .findById(req.params.id)
-    .then(function(event) {
-      if (!event) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(event, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(event);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a event from the DB.
-exports.destroy = function(req, res) {
-  Event
-    .findById(req.params.id)
-    .then(function(event) {
-      if (!event) {
-        return res.sendStatus(404);
-      }
-      event.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/event/event.socket.js b/server/api/event/event.socket.js
index cf6f9ec..9bf13a6 100644
--- a/server/api/event/event.socket.js
+++ b/server/api/event/event.socket.js
@@ -1,36 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Event = require('../../models').Event;
-
-exports.register = function(socket) {
-  Event.afterCreate(function(doc) {
-    Event
-      .findOne({
-        where: {
-          id: doc.id
-        },
-        include: [{
-          all: true
-        }]
-      })
-      .then(function(event) {
-        onSave(socket, event);
-      });
-  });
-
-  Event.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit(('event:' + doc.channel + ':save').toLowerCase(), doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('event:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/event/event.spec.js b/server/api/event/event.spec.js
index 190d585..3ea20f8 100644
--- a/server/api/event/event.spec.js
+++ b/server/api/event/event.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/events', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/events')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/event/index.js b/server/api/event/index.js
index d23b18d..7838b4f 100644
--- a/server/api/event/index.js
+++ b/server/api/event/index.js
@@ -1,16 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./event.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/channel/:channel', controller.showByChannel);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/fax_account/fax_account.controller.js b/server/api/fax_account/fax_account.controller.js
index d550303..2eb6971 100644
--- a/server/api/fax_account/fax_account.controller.js
+++ b/server/api/fax_account/fax_account.controller.js
@@ -1,374 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var async = require('async');
-
-var Trunk = require('../../models').Trunk;
-var FaxAccount = require('../../models').FaxAccount;
-var FaxApplication = require('../../models').FaxApplication;
-var VoiceExtension = require('../../models').VoiceExtension;
-var sequelize = require('../../models').sequelize;
-
-// Get list of agents
-exports.index = function(req, res, next) {
-
-  var attributes = ['description', 'name', 'phone'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  FaxAccount
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single faxAccount
-exports.show = function(req, res, next) {
-  FaxAccount
-    .findById(req.params.id)
-    .then(function(faxAccount) {
-      if (!faxAccount) {
-        return res.sendStatus(404);
-      }
-      return res.send(faxAccount);
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Creates a new faxAccount in the DB.
-exports.create = function(req, res, next) {
-  // console.log(req.body);
-  return sequelize
-    .transaction()
-    .then(function(t) {
-      async.waterfall([
-        function(callback) {
-          return FaxAccount
-            .create(req.body, {
-              transaction: t
-            })
-            .then(function(faxAccount) {
-              callback(null, faxAccount);
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        },
-        function(faxAccount, callback) {
-          return Trunk
-            .findById(req.body.TrunkId, {
-              transaction: t
-            })
-            .then(function(faxTrunk) {
-              callback(null, faxAccount, faxTrunk);
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        },
-        function(faxAccount, faxTrunk, callback) {
-          return VoiceExtension
-            .create({
-              context: faxTrunk.context,
-              exten: req.body.phone,
-              priority: 1,
-              app: 'Goto',
-              appdata: 'inbound-fax,s,1',
-              type: 'inbound-fax',
-              TrunkId: faxTrunk.id
-            }, {
-              transaction: t
-            })
-            .then(function(voiceExtension) {
-              callback(null, faxAccount);
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        }
-      ], function(err, faxAccount) {
-        if (err) {
-          console.log(err);
-          t.rollback();
-          return res.status(404).send(err);
-        } else {
-          console.log('ok');
-          t.commit();
-          return res.status(201).send(faxAccount);
-        }
-      })
-    });
-};
-
-// Updates an existing faxAccount in the DB.
-exports.update = function(req, res, next) {
-  // console.log(req.body);
-  // console.log(req.params);
-
-  if (req.body.id) {
-    delete req.body.id;
-  }
-
-  return sequelize
-    .transaction()
-    .then(function(t) {
-      async.waterfall([
-        function(callback) {
-          return FaxAccount
-            .findOne({
-              where: {
-                id: req.params.id
-              },
-              include: [{
-                model: Trunk
-              }]
-            }, {
-              transaction: t
-            })
-            .then(function(faxAccount) {
-              callback(null, faxAccount);
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        },
-        function(faxAccount, callback) {
-          return Trunk
-            .findById(req.body.TrunkId, {
-              transaction: t
-            })
-            .then(function(trunk) {
-              return faxAccount
-                .updateAttributes({
-                  TrunkId: trunk.id
-                }, {
-                  transaction: t
-                })
-                .then(function(data) {
-                  callback(null, faxAccount, trunk);
-                })
-                .catch(function(err) {
-                  callback(err);
-                });
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        },
-        function(faxAccount, trunk, callback) {
-          return VoiceExtension
-            .findOne({
-              where: {
-                priority: 1,
-                exten: faxAccount.phone,
-                context: faxAccount.Trunk.context
-              }
-            }, {
-              transaction: t
-            })
-            .then(function(voiceExtension) {
-              if (!voiceExtension) {
-                callback(null, faxAccount);
-              }
-              return voiceExtension
-                .updateAttributes({
-                  exten: req.body.phone,
-                  context: trunk.context,
-                  TrunkId: req.body.UserId
-                }, {
-                  transaction: t
-                })
-                .then(function() {
-                  console.log('voiceExtension edited');
-                  callback(null, faxAccount);
-                })
-                .catch(function(err) {
-                  callback(err);
-                });
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        },
-        function(faxAccount, callback) {
-          var updated = _.merge(faxAccount, req.body);
-          return updated.save({
-              transaction: t
-            })
-            .then(function() {
-              console.log('faxAccount saved');
-              callback(null, faxAccount);
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        }
-      ], function(err, faxAccount) {
-        if (err) {
-          console.log(err);
-          t.rollback();
-          return res.status(404).send(err);
-        } else {
-          console.log('ok');
-          t.commit();
-          return res.status(201).send(faxAccount);
-        }
-      })
-    });
-};
-
-// Deletes a faxAccount from the DB.
-exports.destroy = function(req, res, next) {
-  FaxAccount
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(faxAccount) {
-      if (!faxAccount) {
-        return res.sendStatus(404);
-      }
-      faxAccount.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          next(err);
-        });
-    })
-    .catch(function(err) {
-      next(err);
-    });
-};
-
-exports.addApplications = function(req, res, next) {
-
-  FaxApplication
-    .findAll({
-      where: {
-        id: req.body.applications
-      }
-    })
-    .then(function(faxApplications) {
-      var tmpFaxApplications = faxApplications;
-
-      return sequelize.transaction(function(t) {
-        return FaxApplication.destroy({
-          where: {
-            id: req.body.applications
-          }
-        }, {
-          transaction: t
-        }).then(function() {
-
-          var sortedApplications = [];
-
-          for (var i = 0; i < req.body.applications.length; i++) {
-
-            var tmpFaxApplication = _.find(tmpFaxApplications, {
-              'id': req.body.applications[i]
-            });
-
-            if (tmpFaxApplication) {
-              tmpFaxApplication.priority = i + 1;
-              sortedApplications.push(tmpFaxApplication.dataValues);
-            }
-          }
-
-          return FaxApplication.bulkCreate(sortedApplications, {
-            transaction: t
-          }).then(function(data) {
-            return data;
-          });
-        });
-      }).then(function(result) {
-        return res.status(200).send(result);
-        // Transaction has been committed
-        // result is whatever the result of the promise chain returned to the transaction callback
-      }).catch(function(err) {
-        return handleError(res, err);
-        // Transaction has been rolled back
-        // err is whatever rejected the promise chain returned to the transaction callback
-      });
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-exports.bulkDestroy = function(req, res) {
-  FaxAccount
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/fax_account/fax_account.socket.js b/server/api/fax_account/fax_account.socket.js
index e28dde9..9566008 100644
--- a/server/api/fax_account/fax_account.socket.js
+++ b/server/api/fax_account/fax_account.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var fax_account = require('../../models').FaxAccount;
-
-exports.register = function(socket) {
-  fax_account.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  fax_account.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('fax_account:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('fax_account:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/fax_account/fax_account.spec.js b/server/api/fax_account/fax_account.spec.js
index 0399e33..fd6ffa7 100644
--- a/server/api/fax_account/fax_account.spec.js
+++ b/server/api/fax_account/fax_account.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/fax/accounts', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/fax/accounts')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/fax_account/index.js b/server/api/fax_account/index.js
index 15886c9..152f5a6 100644
--- a/server/api/fax_account/index.js
+++ b/server/api/fax_account/index.js
@@ -1,17 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./fax_account.controller');
-var auth = require('../../auth/auth.service');
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.post('/:id/applications', controller.addApplications);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/', controller.bulkDestroy);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/fax_application/fax_application.controller.js b/server/api/fax_application/fax_application.controller.js
index 59b09cb..deca5a6 100644
--- a/server/api/fax_application/fax_application.controller.js
+++ b/server/api/fax_application/fax_application.controller.js
@@ -1,94 +1 @@
-'use strict';
-var _ = require('lodash');
-var FaxApplication = require('../../models').FaxApplication;
-// Get list of fax_applications
-exports.index = function(req, res) {
-  FaxApplication.findAll({
-    where: req.query
-  }).then(function(fax_applications) {
-    return res.status(200).send(fax_applications);
-  }).catch(function(err) {
-    return handleError(res, err);
-  });
-};
-// Get a single fax_application
-exports.show = function(req, res) {
-  FaxApplication.findById(req.params.id).then(function(fax_application) {
-    if (!fax_application) {
-      return res.sendStatus(404);
-    }
-    return res.send(fax_application);
-  }).catch(function(err) {
-    return handleError(res, err);
-  });
-};
-// Creates a new fax_application in the DB.
-exports.create = function(req, res, next) {
-  console.log(req.body);
-  FaxApplication.max('priority', {
-    where: {
-      FaxAccountId: req.body.FaxAccountId
-    }
-  }).then(function(max) {
-    // SET PRIORITY
-    req.body.priority = max ? ++max : 1;
-    FaxApplication.create(req.body).then(function(faxApplication) {
-      return res.status(201).send(faxApplication);
-    }).catch(function(err) {
-      return next(err);
-    });
-    console.log(max);
-  }).catch(function(err) {
-    next(err);
-  });
-  // FaxApplication
-  // .create(req.body)
-  // .then(function(fax_application) {
-  //   return res.status(201).send(fax_application);
-  // })
-  // .catch(function(err) {
-  //   return handleError(res, err);
-  // });
-};
-// Updates an existing fax_application in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  FaxApplication.findById(req.params.id).then(function(fax_application) {
-    if (!fax_application) {
-      return res.sendStatus(404);
-    }
-    var updated = _.merge(fax_application, req.body);
-    updated.save().then(function() {
-      return res.status(200).send(fax_application);
-    }).catch(function(err) {
-      return handleError(res, err);
-    });
-  }).catch(function(err) {
-    return handleError(res, err);
-  });
-};
-// Deletes a fax_application from the DB.
-exports.destroy = function(req, res) {
-  FaxApplication.find({
-    where: {
-      id: req.params.id
-    }
-  }).then(function(fax_application) {
-    if (!fax_application) {
-      return res.sendStatus(404);
-    }
-    fax_application.destroy().then(function() {
-      return res.sendStatus(204);
-    }).catch(function(err) {
-      return handleError(res, err);
-    });
-  }).catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/fax_application/fax_application.socket.js b/server/api/fax_application/fax_application.socket.js
index 2a677d7..7a37458 100644
--- a/server/api/fax_application/fax_application.socket.js
+++ b/server/api/fax_application/fax_application.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var fax_application = require('../../models').FaxApplication;
-
-exports.register = function(socket) {
-  fax_application.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  fax_application.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('fax_application:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('fax_application:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/fax_application/fax_application.spec.js b/server/api/fax_application/fax_application.spec.js
index 9eeaee8..aea9991 100644
--- a/server/api/fax_application/fax_application.spec.js
+++ b/server/api/fax_application/fax_application.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/fax/applications', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/fax/applications')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/fax_application/index.js b/server/api/fax_application/index.js
index b27e419..93b582a 100644
--- a/server/api/fax_application/index.js
+++ b/server/api/fax_application/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./fax_application.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/fax_business_automation/fax_business_automation.controller.js b/server/api/fax_business_automation/fax_business_automation.controller.js
index 2f7a289..40df57f 100644
--- a/server/api/fax_business_automation/fax_business_automation.controller.js
+++ b/server/api/fax_business_automation/fax_business_automation.controller.js
@@ -1,204 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var FaxBusinessAutomation = require('../../models').FaxBusinessAutomation;
-var BusinessCondition = require('../../models').BusinessCondition;
-var BusinessAction = require('../../models').BusinessAction;
-var sequelize = require('../../models').sequelize;
-
-// Get list of fax_business_automations
-exports.index = function(req, res, next) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  FaxBusinessAutomation
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single fax_business_automation
-exports.show = function(req, res) {
-  FaxBusinessAutomation
-    .findById(req.params.id, {
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(fax_business_automation) {
-      if (!fax_business_automation) {
-        return res.sendStatus(404);
-      }
-      return res.send(fax_business_automation);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new fax_business_automation in the DB.
-exports.create = function(req, res, next) {
-  return sequelize.transaction(function(t) {
-      return FaxBusinessAutomation
-        .create(req.body, {
-          transaction: t
-        })
-        .then(function(faxBusinessAutomation) {
-          var conditions = [];
-          if (req.body.or) {
-            req.body.or.forEach(function(elm) {
-              elm.FaxBusinessAutomationId = faxBusinessAutomation.id;
-            });
-            conditions = conditions.concat(req.body.or);
-          }
-
-          if (req.body.and) {
-            req.body.and.forEach(function(elm) {
-              elm.FaxBusinessAutomationId = faxBusinessAutomation.id;
-            });
-            conditions = conditions.concat(req.body.and);
-          }
-
-          return BusinessCondition
-            .bulkCreate(conditions, {
-              transaction: t
-            })
-            .then(function(businessCondtions) {
-              if (req.body.actions) {
-                req.body.actions.forEach(function(elm) {
-                  elm.FaxBusinessAutomationId = faxBusinessAutomation.id;
-                });
-              }
-
-              return BusinessAction
-                .bulkCreate(req.body.actions, {
-                  transaction: t
-                });
-            });
-        })
-    })
-    .then(function() {
-      // Transaction has been committed
-      // result is whatever the result of the promise chain returned to the transaction callback
-      return res.sendStatus(201);
-    }).catch(function(err) {
-      // Transaction has been rolled back
-      // err is whatever rejected the promise chain returned to the transaction callback
-      return next(err);
-    });
-};
-
-// Updates an existing fax_business_automation in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  FaxBusinessAutomation
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(fax_business_automation) {
-      if (!fax_business_automation) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(fax_business_automation, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(fax_business_automation);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a fax_business_automation from the DB.
-exports.destroy = function(req, res) {
-  FaxBusinessAutomation
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(fax_business_automation) {
-      if (!fax_business_automation) {
-        return res.sendStatus(404);
-      }
-      fax_business_automation.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/fax_business_automation/fax_business_automation.socket.js b/server/api/fax_business_automation/fax_business_automation.socket.js
index 5f03434..1d49461 100644
--- a/server/api/fax_business_automation/fax_business_automation.socket.js
+++ b/server/api/fax_business_automation/fax_business_automation.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var FaxBusinessAutomation = require('../../models').FaxBusinessAutomation;
-
-exports.register = function(socket) {
-  FaxBusinessAutomation.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  FaxBusinessAutomation.afterUpdate(function(doc, options) {
-    onSave(socket, doc);
-  });
-  FaxBusinessAutomation.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('fax_business_automation:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('fax_business_automation:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/fax_business_automation/fax_business_automation.spec.js b/server/api/fax_business_automation/fax_business_automation.spec.js
index f9f7234..077f800 100644
--- a/server/api/fax_business_automation/fax_business_automation.spec.js
+++ b/server/api/fax_business_automation/fax_business_automation.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/fax/business/automations', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/fax/business/automations')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/fax_business_automation/index.js b/server/api/fax_business_automation/index.js
index ad01841..07cf571 100644
--- a/server/api/fax_business_automation/index.js
+++ b/server/api/fax_business_automation/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./fax_business_automation.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/fax_message/fax_message.ami.js b/server/api/fax_message/fax_message.ami.js
index 2d69e42..9fa23ff 100644
--- a/server/api/fax_message/fax_message.ami.js
+++ b/server/api/fax_message/fax_message.ami.js
@@ -1,64 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var FaxMessage = require('../../models').FaxMessage;
-var Trunk = require('../../models').User;
-
-exports.register = function(ami) {
-
-  FaxMessage.afterCreate(function(doc) {
-    console.log('FaxMessage afterCreate');
-    onSave(ami, doc);
-  });
-};
-
-function onSave(ami, doc, cb) {
-  if (doc.status === 'NOT SENT' && !doc.actionid) {
-    // I have to send the fax with the Originate
-    var faxBody = JSON.parse(doc.body);
-    console.log('faxBody', faxBody);
-
-    Trunk
-      .findById(faxBody.trunk.id)
-      .then(function(trunk) {
-        var action = {
-          Action: 'originate',
-          CallerID: faxBody.from,
-          Channel: util.format('%s/%s@%s', faxBody.technology, faxBody.to, trunk.name),
-          Context: 'outbound-fax',
-          Exten: 's',
-          Priority: 1,
-          Async: 'true',
-          Variable: {
-            MAXRATE: faxBody.maxrate,
-            MINRATE: faxBody.minrate,
-            ECM: faxBody.ecm ? 'yes' : 'no',
-            LOCALID: faxBody.fax_localid,
-            FAXFILE: faxBody.fax_file,
-            // 'FAXFILE': 'test.tiff', // Scommentare se si fanno prove in locale!
-            FAXHEADER: faxBody.fax_header,
-            FAXUUID: faxBody.uuid
-          }
-        };
-
-        ami.action(action, function(err, res) {
-          if (err) {
-            doc.updateAttributes({
-              status: 'FAILED'
-            });
-          } else {
-            if (res.response && res.actionid) {
-              doc.updateAttributes({
-                actionid: res.actionid
-              });
-            }
-          }
-        });
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  }
-}
\ No newline at end of file
diff --git a/server/api/fax_message/fax_message.controller.js b/server/api/fax_message/fax_message.controller.js
index e354d5f..3893137 100644
--- a/server/api/fax_message/fax_message.controller.js
+++ b/server/api/fax_message/fax_message.controller.js
@@ -1,422 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var fs = require('fs');
-var path = require('path');
-var uploadFile = require('upload-file');
-var uuidLib = require('node-uuid');
-var pdf = require('html-pdf');
-var spindrift = require('spindrift');
-var formidable = require('formidable');
-var exec = require('child_process').exec;
-var config = require('../../config/environment');
-
-var FaxMessage = require('../../models').FaxMessage;
-var FaxRoom = require('../../models').FaxRoom;
-var FaxAccount = require('../../models').FaxAccount;
-var Contact = require('../../models').Contact;
-
-// Get list of fax_messages
-exports.index = function(req, res) {
-  FaxMessage
-    .findAll({
-      where: req.query,
-      order: 'createdAt DESC',
-      include: [{
-        model: Contact,
-        as: 'From'
-      }, {
-        model: Contact,
-        as: 'To'
-      }, {
-        model: FaxRoom,
-        include: [{
-          model: FaxAccount
-        }]
-      }]
-    })
-    .then(function(fax_messages) {
-      return res.status(200).send(fax_messages);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single fax_message
-exports.show = function(req, res) {
-  FaxMessage
-    .findOne({
-      where: {
-        id: req.params.id
-      },
-      include: [{
-        model: Contact,
-        as: 'From'
-      }, {
-        model: Contact,
-        as: 'To'
-      }]
-    })
-    .then(function(fax_message) {
-      if (!fax_message) {
-        return res.sendStatus(404);
-      }
-      return res.send(fax_message);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new fax_message in the DB.
-exports.create = function(req, res, next) {
-  // FaxMessage
-  //   .create(req.body)
-  //   .then(function(fax_message) {
-  //     return res.status(201).send(fax_message);
-  //   })
-  //   .catch(function(err) {
-  //     return handleError(res, err);
-  //   });
-
-  var form = new formidable.IncomingForm();
-  // form.encoding = 'utf-8';
-  form.uploadDir = path.join(config.root, 'server/files/fax/outbound/original');
-  form.keepExtensions = true;
-  form.multiples = false;
-
-  if (req.body.onlyText) {
-    //There is not file, only text
-    // console.log(req.body);
-    if (req.body.html) {
-      //There is the html message -> convert
-      var uuid = uuidLib.v4()
-      var dest = path.join(config.root, 'server/files/fax/outbound/original', uuid + '.pdf');
-      pdf.create(req.body.html, {
-        "timeout": 30000
-      }).toFile(dest, function(err, result) {
-        console.log('Fax: HTML Converted');
-        convertPdfAndSendFax(req, res, uuid, req.body);
-      });
-    }
-  } else {
-    form.parse(req, function(err, fields, files) {
-      if (err) {
-        return handleError(res, err);
-      }
-
-      if (fields.html) {
-        //There is HTML with PDF
-        var uuid = uuidLib.v4();
-        var dest = path.join(config.root, 'server/files/fax/outbound/original', uuid + '.pdf');
-        pdf.create(fields.html, {
-          "timeout": 30000
-        }).toFile(dest, function(err, result) {
-          console.log('Fax: HTML Converted');
-          var pdfHTML = spindrift(result.filename);
-          var pdfUploaded = spindrift(files.file.path);
-          var uuid = uuidLib.v4();
-          spindrift.join(pdfHTML, pdfUploaded).pdfStream().pipe(fs.createWriteStream(path.join(config.root, 'server/files/fax/outbound/original', uuid + '.pdf')));
-          console.log('Fax: HTML joined with PDF uploaded');
-          convertPdfAndSendFax(req, res, uuid, fields);
-        });
-      } else {
-        //There is only PDF
-        var uuid = uuidLib.v4();
-        var dest = path.join(config.root, 'server/files/fax/outbound/original', uuid + '.pdf');
-        fs.rename(files.file.path, dest, function(err) {
-          if (err) {
-            console.error(err);
-            return handleError(res, req);
-            // return next(err);
-          }
-          console.log('Fax: PDF Rename');
-          convertPdfAndSendFax(req, res, uuid, fields);
-        });
-      }
-
-    });
-  }
-};
-
-function convertPdfAndSendFax(req, res, filenameInput, fields) {
-  var inputPath = path.join(config.root, 'server', 'files', 'fax', 'outbound', 'original', filenameInput + '.pdf');
-  var resultPath = path.join(config.root, 'server', 'files', 'fax', 'outbound', 'converted', filenameInput + '.tif');
-  var command = 'gs' + ' -q -dNOPAUSE -dBATCH -sDEVICE=tiffg4 ' + '-sPAPERSIZE=letter -sOutputFile=' + resultPath + ' ' + inputPath;
-  // console.log(inputPath, resultPath, command);
-
-  var uuidFax = uuidLib.v4();
-  FaxAccount
-    .findById(fields.accountId)
-    .then(function(faxAccount) {
-      // console.log('FaxAccount', faxAccount);
-
-      if (faxAccount) {
-        var faxBody = {
-          technology: 'SIP',
-          to: fields.toNum,
-          from: faxAccount.phone,
-          fax_file: resultPath,
-          fax_header: faxAccount.faxheader,
-          fax_localid: faxAccount.localid,
-          maxrate: faxAccount.maxrate,
-          minrate: faxAccount.minrate,
-          ecm: faxAccount.ecm,
-          uuid: uuidFax,
-          trunk: {
-            id: faxAccount.TrunkId
-          }
-        };
-
-        fs.exists(inputPath, function(exists) {
-          if (!exists) {
-            // console.log('File not exist');
-            handleError(res, new Error('File not exists'));
-          } else {
-            exec(command, function(err) {
-              if (err) {
-                console.error(err);
-                handleError(res, err);
-              } else {
-                console.log('Fax: PDF converted to TIFF');
-                fs.chmod(resultPath, 511, function(err) {
-                  if (fields.roomId) {
-                    // Room already exists -> create new message and associate
-                    FaxRoom
-                      .findOrCreate({
-                        where: {
-                          id: fields.roomId
-                        },
-                        defaults: {}
-                      })
-                      .spread(function(faxRoom, created) {
-                        // TODO Verify if we have to manage also the created
-                        FaxMessage
-                          .create({
-                            status: 'NOT SENT',
-                            read: true,
-                            filenamePDF: filenameInput + '.pdf',
-                            filename: filenameInput + '.tif',
-                            body: JSON.stringify(faxBody),
-                            uuid: uuidFax,
-                            FaxRoomId: faxRoom.id
-                          })
-                          .then(function(faxMessage) {
-                            // Fax message created, now association
-                            Contact
-                              .findOrCreate({
-                                where: {
-                                  phone: faxBody.from
-                                },
-                                defaults: {
-                                  phone: faxBody.from,
-                                  fullname: faxBody.from
-                                }
-                              })
-                              .spread(function(contact, created) {
-                                // console.log('Set relationship with from', created);
-                                faxMessage.setFrom(contact);
-                              });
-
-                            Contact
-                              .findOrCreate({
-                                where: {
-                                  phone: faxBody.to
-                                },
-                                defaults: {
-                                  phone: faxBody.to,
-                                  fullname: faxBody.to
-                                }
-                              })
-                              .spread(function(contact, created) {
-                                // console.log('Set relationship with to', created);
-                                faxMessage.setTo(contact);
-                              });
-
-                            return res.status(200).send(faxMessage);
-                          })
-                          .catch(function(err) {
-                            handleError(res, err);
-                            // console.error(err);
-                            // next(err);
-                          });
-                      });
-                  } else {
-                    // Room not exists -> create room, message and associate
-                    FaxRoom
-                      .create({
-                        status: 'OPEN',
-                        from: fields.toNum,
-                        FaxAccountId: fields.accountId,
-                        UserId: fields.userId
-                      })
-                      .then(function(faxRoom) {
-                        // Room created, now message
-                        FaxMessage
-                          .create({
-                            status: 'NOT SENT',
-                            read: true,
-                            filenamePDF: filenameInput + '.pdf',
-                            filename: filenameInput + '.tif',
-                            body: JSON.stringify(faxBody),
-                            uuid: uuidFax,
-                            FaxRoomId: faxRoom.id
-                          })
-                          .then(function(faxMessage) {
-                            // Fax message created, now association
-
-                            Contact
-                              .findOrCreate({
-                                where: {
-                                  phone: faxBody.from
-                                },
-                                defaults: {
-                                  phone: faxBody.from,
-                                  fullname: faxBody.from
-                                }
-                              })
-                              .spread(function(contact, created) {
-                                faxMessage.setFrom(contact);
-                              });
-
-                            Contact
-                              .findOrCreate({
-                                where: {
-                                  phone: faxBody.to
-                                },
-                                defaults: {
-                                  phone: faxBody.to,
-                                  fullname: faxBody.to
-                                }
-                              })
-                              .spread(function(contact, created) {
-                                faxMessage.setTo(contact);
-                              });
-
-                            return res.status(200).send(
-                              faxMessage);
-                          })
-                          .catch(function(err) {
-                            handleError(res, err);
-                          });
-                      })
-                      .catch(function(err) {
-                        handleError(res, err);
-                      });
-                  }
-                });
-              }
-            });
-          }
-        });
-      }
-    });
-}
-
-// Updates an existing fax_message in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  FaxMessage
-    .findOne({
-      where: {
-        id: req.params.id
-      },
-      include: [{
-        model: Contact,
-        as: 'From'
-      }, {
-        model: Contact,
-        as: 'To'
-      }]
-    })
-    .then(function(fax_message) {
-      if (!fax_message) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(fax_message, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(fax_message);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a fax_message from the DB.
-exports.destroy = function(req, res) {
-  FaxMessage
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(fax_message) {
-      if (!fax_message) {
-        return res.sendStatus(404);
-      }
-      fax_message.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.getContentFromMessage = function(req, res) {
-
-  FaxMessage
-    .findById(req.params.id)
-    .then(function(fax_message) {
-
-      // console.log(fax_message);
-
-      if (!fax_message) {
-        return res.sendStatus(404);
-      }
-
-      if (fax_message.filenamePDF) {
-
-        if (fax_message.status === 'RECEIVED') {
-          var pdfPath = path.join(config.root, 'server', 'files', 'fax', 'inbound', fax_message.filenamePDF);
-          fs.exists(pdfPath, function(exists) {
-            if (exists)
-              return res.sendFile(pdfPath);
-            else
-              return res.sendStatus(404);
-          });
-        } else if (fax_message.status === 'NOT SENT' || fax_message.directory ===
-          'SENT' || fax_message.status === 'FAILED') {
-          var pdfPath = path.join(config.root, 'server', 'files', 'fax', 'outbound', 'original', fax_message.filenamePDF);
-          fs.exists(pdfPath, function(exists) {
-            if (exists)
-              return res.sendFile(pdfPath);
-            else
-              return res.sendStatus(404);
-          });
-        }
-      } else {
-        res.sendStatus(404);
-      }
-
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/fax_message/fax_message.socket.js b/server/api/fax_message/fax_message.socket.js
index 79a31ad..00e490f 100644
--- a/server/api/fax_message/fax_message.socket.js
+++ b/server/api/fax_message/fax_message.socket.js
@@ -1,85 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var FaxMessage = require('../../models').FaxMessage;
-var Contact = require('../../models').Contact;
-var FaxRoom = require('../../models').FaxRoom;
-var FaxAccount = require('../../models').FaxAccount;
-
-exports.register = function(socket) {
-  FaxMessage.afterCreate(function(doc) {
-    FaxMessage
-      .findOne({
-        where: {
-          id: doc.id
-        },
-        include: [{
-          model: Contact,
-          as: 'From'
-        }, {
-          model: Contact,
-          as: 'To'
-        }, {
-          model: FaxRoom,
-          include: [{
-            model: FaxAccount
-          }]
-        }]
-      })
-      .then(function(faxMessage) {
-        onSave(socket, faxMessage);
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  });
-
-  FaxMessage.afterUpdate(function(doc) {
-    FaxMessage
-      .findOne({
-        where: {
-          id: doc.id
-        },
-        include: [{
-          model: Contact,
-          as: 'From'
-        }, {
-          model: Contact,
-          as: 'To'
-        }, {
-          model: FaxRoom,
-          include: [{
-            model: FaxAccount
-          }]
-        }]
-      })
-      .then(function(faxMessage) {
-        onSave(socket, faxMessage);
-        onUpdate(socket, faxMessage);
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  });
-
-  FaxMessage.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('fax_message:save', doc);
-  // socket.emit('fax_message:' + doc.directory + ':save', doc);
-}
-
-function onUpdate(socket, doc, cb) {
-  socket.emit('fax_message:update', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('fax_message:remove', doc);
-  // socket.emit('fax_message:' + doc.directory + ':remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/fax_message/fax_message.spec.js b/server/api/fax_message/fax_message.spec.js
index d61f66e..bd6605c 100644
--- a/server/api/fax_message/fax_message.spec.js
+++ b/server/api/fax_message/fax_message.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/fax/messages', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/fax/messages')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/fax_message/index.js b/server/api/fax_message/index.js
index b237a79..d3e7121 100644
--- a/server/api/fax_message/index.js
+++ b/server/api/fax_message/index.js
@@ -1,16 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./fax_message.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id/content', controller.getContentFromMessage);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/fax_queue/fax_queue.controller.js b/server/api/fax_queue/fax_queue.controller.js
index c5157bb..220cb67 100644
--- a/server/api/fax_queue/fax_queue.controller.js
+++ b/server/api/fax_queue/fax_queue.controller.js
@@ -1,222 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var FaxQueue = require('../../models').FaxQueue;
-
-// Get list of fax_queues
-exports.index = function(req, res) {
-
-  var attributes = ['description', 'name', 'timeout', 'strategy'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page,
-    include: [{
-      all: true
-    }]
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  FaxQueue
-    .findAndCountAll(query)
-    .then(function(result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single fax_queue
-exports.show = function(req, res) {
-  FaxQueue
-    .findById(req.params.id)
-    .then(function(fax_queue) {
-      if (!fax_queue) {
-        return res.sendStatus(404);
-      }
-      return res.send(fax_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new fax_queue in the DB.
-exports.create = function(req, res) {
-  FaxQueue
-    .create(req.body)
-    .then(function(fax_queue) {
-      return res.status(201).send(fax_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing fax_queue in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  FaxQueue
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(fax_queue) {
-      if (!fax_queue) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(fax_queue, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(fax_queue);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a fax_queue from the DB.
-exports.destroy = function(req, res) {
-  FaxQueue
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(fax_queue) {
-      if (!fax_queue) {
-        return res.sendStatus(404);
-      }
-      fax_queue.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.addAgents = function(req, res, next) {
-  FaxQueue
-    .findById(req.params.id)
-    .then(function(faxQueue) {
-      if (faxQueue) {
-        // QUEUE FOUND
-        // ADD AGENTS
-        faxQueue
-          .addUsers(req.body.agents)
-          .then(function() {
-            return res.sendStatus(200);
-          })
-          .catch(function(err) {
-            return next(err);
-          });
-      } else {
-        return next(new Error('no fax queue found'));
-      }
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-exports.removeAgents = function(req, res, next) {
-  FaxQueue
-    .findById(req.params.id)
-    .then(function(faxQueue) {
-      if (faxQueue) {
-        // QUEUE FOUND
-        // REMOVE AGENTS
-        faxQueue
-          .removeUsers(req.body.agents)
-          .then(function() {
-            return res.sendStatus(200);
-          })
-          .catch(function(err) {
-            return next(err);
-          });
-      } else {
-        return next(new Error('no fax queue found'));
-      }
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function(req, res) {
-  FaxQueue
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/fax_queue/fax_queue.socket.js b/server/api/fax_queue/fax_queue.socket.js
index 243ed07..c858c04 100644
--- a/server/api/fax_queue/fax_queue.socket.js
+++ b/server/api/fax_queue/fax_queue.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var fax_queue = require('../../models').FaxQueue;
-
-exports.register = function(socket) {
-  fax_queue.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  fax_queue.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('fax_queue:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('fax_queue:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/fax_queue/fax_queue.spec.js b/server/api/fax_queue/fax_queue.spec.js
index 9148967..4a5be14 100644
--- a/server/api/fax_queue/fax_queue.spec.js
+++ b/server/api/fax_queue/fax_queue.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/fax/queues', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/fax/queues')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/fax_queue/index.js b/server/api/fax_queue/index.js
index 89f2c19..ff93f3d 100644
--- a/server/api/fax_queue/index.js
+++ b/server/api/fax_queue/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./fax_queue.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.post('/:id/agents', controller.addAgents);
-router.put('/:id', controller.update);
-router.put('/:id/agents', controller.removeAgents);
-router.patch('/:id', controller.update);
-router.delete('/', controller.bulkDestroy);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/fax_room/fax_room.controller.js b/server/api/fax_room/fax_room.controller.js
index a139fd5..7986762 100644
--- a/server/api/fax_room/fax_room.controller.js
+++ b/server/api/fax_room/fax_room.controller.js
@@ -1,151 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var FaxRoom = require('../../models').FaxRoom;
-var FaxAccount = require('../../models').FaxAccount;
-var FaxMessage = require('../../models').FaxMessage;
-var Contact = require('../../models').Contact;
-var User = require('../../models').User;
-
-// Get list of fax_rooms
-exports.index = function(req, res) {
-  FaxRoom
-    .findAll({
-      include: [{
-        model: FaxMessage,
-        attributes: ['id']
-      }, {
-        model: FaxAccount
-      }, {
-        model: User
-      }]
-    })
-    .then(function(fax_rooms) {
-      return res.status(200).send(fax_rooms);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get list of agent mailRooms
-exports.agentIndex = function(req, res, next) {
-  FaxRoom
-    .findAll({
-      where: {
-        UserId: req.params.id
-      },
-      include: [{
-        model: FaxAccount
-      }, {
-        model: User
-      }]
-    })
-    .then(function(faxRooms) {
-      return res.status(200).send(faxRooms);
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Get a single fax_room
-exports.show = function(req, res) {
-  FaxRoom
-    .findOne({
-      where: {
-        id: req.params.id
-      },
-      include: [{
-        model: FaxMessage,
-        include: [{
-          model: FaxRoom,
-          include: [{
-            model: FaxAccount
-          }]
-        }, {
-          model: Contact,
-          as: 'From'
-        }, {
-          model: Contact,
-          as: 'To'
-        }]
-      }, {
-        model: FaxAccount
-      }],
-      order: [
-        [FaxMessage, 'createdAt', 'DESC']
-      ]
-    })
-    .then(function(fax_room) {
-      if (!fax_room) {
-        return res.sendStatus(404);
-      }
-      return res.send(fax_room);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new fax_room in the DB.
-exports.create = function(req, res) {
-  FaxRoom
-    .create(req.body)
-    .then(function(fax_room) {
-      return res.status(201).send(fax_room);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing fax_room in the DB.
-exports.update = function(req, res) {
-  // if (req.body.id) {
-  //   delete req.body.id;
-  // }
-  FaxRoom
-    .findById(req.params.id)
-    .then(function(fax_room) {
-      if (!fax_room) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(fax_room, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(fax_room);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a fax_room from the DB.
-exports.destroy = function(req, res) {
-  FaxRoom
-    .findById(req.params.id)
-    .then(function(fax_room) {
-      if (!fax_room) {
-        return res.sendStatus(404);
-      }
-      fax_room.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/fax_room/fax_room.kue.js b/server/api/fax_room/fax_room.kue.js
index ba9c227..72bd709 100644
--- a/server/api/fax_room/fax_room.kue.js
+++ b/server/api/fax_room/fax_room.kue.js
@@ -1,64 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var User = require('../../models').User;
-var FaxRoom = require('../../models').FaxRoom;
-var FaxQueue = require('../../models').FaxQueue;
-var FaxAccount = require('../../models').FaxAccount;
-var FaxApplication = require('../../models').FaxApplication;
-
-exports.register = function(queue) {
-  FaxRoom.afterCreate(function(doc) {
-    onSave(queue, doc);
-  });
-}
-
-function onSave(queue, doc, cb) {
-  if (doc.status === 'NEW') {
-    FaxAccount
-      .findById(doc.FaxAccountId)
-      .then(function(faxAccount) {
-        faxAccount
-          .getFaxApplications({
-            include: [{
-              model: User,
-              attributes: ['id']
-            }, {
-              model: FaxQueue,
-              attributes: ['id', 'strategy', 'timeout'],
-              include: {
-                model: User,
-                attributes: ['id']
-              }
-            }],
-            order: [
-              ['priority']
-            ]
-          })
-          .then(function(faxApplications) {
-
-            var data = {
-              roomId: doc.id,
-              accountId: doc.FaxAccountId,
-              channel: 'FAX',
-              msg: {
-                from: doc.from
-              },
-              applications: faxApplications
-            };
-
-            // Create queue process
-            queue.create('fax', data).save();
-          })
-          .catch(function(err) {
-            console.error(err);
-          });
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  }
-}
\ No newline at end of file
diff --git a/server/api/fax_room/fax_room.socket.js b/server/api/fax_room/fax_room.socket.js
index 92f71b0..6b3cf56 100644
--- a/server/api/fax_room/fax_room.socket.js
+++ b/server/api/fax_room/fax_room.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var fax_room = require('../../models').FaxRoom;
-
-exports.register = function(socket) {
-  fax_room.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  fax_room.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('fax_room:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('fax_room:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/fax_room/fax_room.spec.js b/server/api/fax_room/fax_room.spec.js
index 1a5ae47..b9881f7 100644
--- a/server/api/fax_room/fax_room.spec.js
+++ b/server/api/fax_room/fax_room.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/fax/rooms', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/fax/rooms')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/fax_room/index.js b/server/api/fax_room/index.js
index 44a0c05..6bc03c2 100644
--- a/server/api/fax_room/index.js
+++ b/server/api/fax_room/index.js
@@ -1,16 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./fax_room.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/agent/:id', controller.agentIndex);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/freshdesk_account/freshdesk_account.controller.js b/server/api/freshdesk_account/freshdesk_account.controller.js
index ae9ab8a..fc01f17 100644
--- a/server/api/freshdesk_account/freshdesk_account.controller.js
+++ b/server/api/freshdesk_account/freshdesk_account.controller.js
@@ -1,239 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/freshdesk/accounts              ->  index
- * POST    /api/freshdesk/accounts              ->  create
- * GET     /api/freshdesk/accounts/:id          ->  show
- * PUT     /api/freshdesk/accounts/:id          ->  update
- * DELETE  /api/freshdesk/accounts/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-var util = require('util');
-var _fd = require('freshdesk');
-
-var FreshdeskAccount = require('../../models').FreshdeskAccount;
-
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of FreshdeskAccounts
-exports.index = function(req, res) {
-  var attributes = ['description', 'name', 'username', 'remoteUri'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  FreshdeskAccount
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      return res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-}
-
-// Gets a single FreshdeskAccount from the DB
-exports.show = function(req, res) {
-  FreshdeskAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new FreshdeskAccount in the DB
-exports.create = function(req, res) {
-  FreshdeskAccount.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing FreshdeskAccount in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  FreshdeskAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a FreshdeskAccount from the DB
-exports.destroy = function(req, res) {
-  FreshdeskAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
-
-exports.bulkDestroy = function(req, res) {
-  FreshdeskAccount
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.checkAccount = function(req, res) {
-  FreshdeskAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(account) {
-      var freshdesk = new _fd(account.remoteUri, account.apiKey);
-      freshdesk.listTickets(function(err, response, body) {
-        if (err) {
-          return res.sendStatus(400);
-        }
-        body = JSON.parse(body);
-        if (body.require_login) {
-          return res.sendStatus(400);
-        }
-        return res.sendStatus(200);
-      })
-    })
-    .catch(handleError(res));
-}
-
-exports.accountValidation = function(req, res) {
-  var where = {};
-  where[req.params.field] = req.body.value;
-  FreshdeskAccount
-    .findAndCountAll({
-      where: where
-    })
-    .then(function(result) {
-      if (result.count) {
-        return res.status(200).send({
-          isValid: false,
-          value: req.body.value
-        });
-      }
-      return res.status(200).send({
-        isValid: true,
-        value: req.body.value
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.getFields = function(req, res, next) {
-  FreshdeskAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(account) {
-      var Freshdesk = new _fd(account.remoteUri, account.apiKey);
-      Freshdesk.get('/ticket_fields.json', function(err, response, body) {
-        if (err) {
-          return next(err);
-        }
-        body = JSON.parse(body);
-        return res.status(200).send(body);
-      });
-    })
-    .catch(handleError(res));
-};
\ No newline at end of file
diff --git a/server/api/freshdesk_account/freshdesk_account.socket.js b/server/api/freshdesk_account/freshdesk_account.socket.js
index 2aabaae..68d35a9 100644
--- a/server/api/freshdesk_account/freshdesk_account.socket.js
+++ b/server/api/freshdesk_account/freshdesk_account.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var FreshdeskAccount = require('../../models').FreshdeskAccount;
-
-exports.register = function(socket) {
-  FreshdeskAccount.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  FreshdeskAccount.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('freshdesk_account:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('freshdesk_account:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/freshdesk_account/index.js b/server/api/freshdesk_account/index.js
index a7385b7..a4bd052 100644
--- a/server/api/freshdesk_account/index.js
+++ b/server/api/freshdesk_account/index.js
@@ -1,21 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./freshdesk_account.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id/fields', auth.isAuthenticated(), controller.getFields);
-router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount);
-router.post('/validate/:field', auth.isAuthenticated(), controller.accountValidation);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/freshdesk_account/index.spec.js b/server/api/freshdesk_account/index.spec.js
index 6d7fc75..193468e 100644
--- a/server/api/freshdesk_account/index.spec.js
+++ b/server/api/freshdesk_account/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var freshdeskAccountCtrlStub = {
-  index: 'freshdeskAccountCtrl.index',
-  show: 'freshdeskAccountCtrl.show',
-  create: 'freshdeskAccountCtrl.create',
-  update: 'freshdeskAccountCtrl.update',
-  destroy: 'freshdeskAccountCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var freshdeskAccountIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './freshdesk_account.controller': freshdeskAccountCtrlStub
-});
-
-describe('FreshdeskAccount API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(freshdeskAccountIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/freshdesk/accounts', function() {
-
-    it('should route to freshdeskAccount.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'freshdeskAccountCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/freshdesk/accounts/:id', function() {
-
-    it('should route to freshdeskAccount.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'freshdeskAccountCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/freshdesk/accounts', function() {
-
-    it('should route to freshdeskAccount.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'freshdeskAccountCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/freshdesk/accounts/:id', function() {
-
-    it('should route to freshdeskAccount.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'freshdeskAccountCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/freshdesk/accounts/:id', function() {
-
-    it('should route to freshdeskAccount.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'freshdeskAccountCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/freshdesk/accounts/:id', function() {
-
-    it('should route to freshdeskAccount.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'freshdeskAccountCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/freshdesk_configuration/freshdesk_configuration.controller.js b/server/api/freshdesk_configuration/freshdesk_configuration.controller.js
index 4c3d44d..3df8df8 100644
--- a/server/api/freshdesk_configuration/freshdesk_configuration.controller.js
+++ b/server/api/freshdesk_configuration/freshdesk_configuration.controller.js
@@ -1,146 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/freshdesk/configurations              ->  index
- * POST    /api/freshdesk/configurations              ->  create
- * GET     /api/freshdesk/configurations/:id          ->  show
- * PUT     /api/freshdesk/configurations/:id          ->  update
- * DELETE  /api/freshdesk/configurations/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-
-var FreshdeskConfiguration = require('../../models').FreshdeskConfiguration;
-var FreshdeskField = require('../../models').FreshdeskField;
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of FreshdeskConfigurations
-exports.index = function(req, res) {
-  FreshdeskConfiguration.findAll({
-      where: req.query
-    })
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Gets a single FreshdeskConfiguration from the DB
-exports.show = function(req, res) {
-  FreshdeskConfiguration.find({
-      where: {
-        id: req.params.id
-      },
-      include: [{
-        model: FreshdeskField,
-        as: 'Subject'
-      }, {
-        model: FreshdeskField,
-        as: 'Description'
-      }, {
-        model: FreshdeskField,
-        as: 'Field'
-      }]
-    })
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new FreshdeskConfiguration in the DB
-exports.create = function(req, res) {
-  FreshdeskConfiguration.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing FreshdeskConfiguration in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  FreshdeskConfiguration.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a FreshdeskConfiguration from the DB
-exports.destroy = function(req, res) {
-  FreshdeskConfiguration.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
-
-exports.addConfigurationField = function(req, res, next) {
-  // console.log(req.params);
-  var freshdeskConfiguration;
-  FreshdeskConfiguration
-    .findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(salesforce_configuration) {
-      freshdeskConfiguration = salesforce_configuration;
-      return FreshdeskField.create(req.body)
-    })
-    .then(function(freshdeskField) {
-      switch (req.params.type) {
-        case 'subject':
-          return [freshdeskConfiguration.addSubject(freshdeskField), freshdeskField];
-        case 'description':
-          return [freshdeskConfiguration.addDescription(freshdeskField), freshdeskField];
-        case 'field':
-          return [freshdeskConfiguration.addField(freshdeskField), freshdeskField];
-      }
-    })
-    .spread(function(data, freshdeskField) {
-      return res.status(201).json(freshdeskField);
-    })
-    .catch(handleError(res));
-};
\ No newline at end of file
diff --git a/server/api/freshdesk_configuration/freshdesk_configuration.socket.js b/server/api/freshdesk_configuration/freshdesk_configuration.socket.js
index 4ce7f30..65c7201 100644
--- a/server/api/freshdesk_configuration/freshdesk_configuration.socket.js
+++ b/server/api/freshdesk_configuration/freshdesk_configuration.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var FreshdeskConfiguration = require('../../models').FreshdeskConfiguration;
-
-exports.register = function(socket) {
-  FreshdeskConfiguration.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  FreshdeskConfiguration.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('freshdesk_configuration:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('freshdesk_configuration:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/freshdesk_configuration/index.js b/server/api/freshdesk_configuration/index.js
index e08945f..b2b778a 100644
--- a/server/api/freshdesk_configuration/index.js
+++ b/server/api/freshdesk_configuration/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./freshdesk_configuration.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/freshdesk_configuration/index.spec.js b/server/api/freshdesk_configuration/index.spec.js
index b297c23..3254e77 100644
--- a/server/api/freshdesk_configuration/index.spec.js
+++ b/server/api/freshdesk_configuration/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var freshdeskConfigurationCtrlStub = {
-  index: 'freshdeskConfigurationCtrl.index',
-  show: 'freshdeskConfigurationCtrl.show',
-  create: 'freshdeskConfigurationCtrl.create',
-  update: 'freshdeskConfigurationCtrl.update',
-  destroy: 'freshdeskConfigurationCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var freshdeskConfigurationIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './freshdesk_configuration.controller': freshdeskConfigurationCtrlStub
-});
-
-describe('FreshdeskConfiguration API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(freshdeskConfigurationIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/freshdesk/configurations', function() {
-
-    it('should route to freshdeskConfiguration.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'freshdeskConfigurationCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/freshdesk/configurations/:id', function() {
-
-    it('should route to freshdeskConfiguration.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'freshdeskConfigurationCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/freshdesk/configurations', function() {
-
-    it('should route to freshdeskConfiguration.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'freshdeskConfigurationCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/freshdesk/configurations/:id', function() {
-
-    it('should route to freshdeskConfiguration.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'freshdeskConfigurationCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/freshdesk/configurations/:id', function() {
-
-    it('should route to freshdeskConfiguration.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'freshdeskConfigurationCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/freshdesk/configurations/:id', function() {
-
-    it('should route to freshdeskConfiguration.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'freshdeskConfigurationCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/freshdesk_field/freshdesk_field.controller.js b/server/api/freshdesk_field/freshdesk_field.controller.js
index 4a35db8..386e4f4 100644
--- a/server/api/freshdesk_field/freshdesk_field.controller.js
+++ b/server/api/freshdesk_field/freshdesk_field.controller.js
@@ -1,104 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/freshdesk/fields              ->  index
- * POST    /api/freshdesk/fields              ->  create
- * GET     /api/freshdesk/fields/:id          ->  show
- * PUT     /api/freshdesk/fields/:id          ->  update
- * DELETE  /api/freshdesk/fields/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-
-var FreshdeskField = require('../../models').FreshdeskField;
-
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of FreshdeskFields
-exports.index = function(req, res) {
-  FreshdeskField.findAll()
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Gets a single FreshdeskField from the DB
-exports.show = function(req, res) {
-  FreshdeskField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new FreshdeskField in the DB
-exports.create = function(req, res) {
-  FreshdeskField.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing FreshdeskField in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  FreshdeskField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a FreshdeskField from the DB
-exports.destroy = function(req, res) {
-  FreshdeskField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
\ No newline at end of file
diff --git a/server/api/freshdesk_field/freshdesk_field.socket.js b/server/api/freshdesk_field/freshdesk_field.socket.js
index b351442..6f16ab8 100644
--- a/server/api/freshdesk_field/freshdesk_field.socket.js
+++ b/server/api/freshdesk_field/freshdesk_field.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var FreshdeskField = require('../../models').FreshdeskField;
-
-exports.register = function(socket) {
-  FreshdeskField.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  FreshdeskField.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('freshdesk_field:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('freshdesk_field:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/freshdesk_field/index.js b/server/api/freshdesk_field/index.js
index d17268f..2f224a5 100644
--- a/server/api/freshdesk_field/index.js
+++ b/server/api/freshdesk_field/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./freshdesk_field.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/freshdesk_field/index.spec.js b/server/api/freshdesk_field/index.spec.js
index b5c0fb8..84edd95 100644
--- a/server/api/freshdesk_field/index.spec.js
+++ b/server/api/freshdesk_field/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var freshdeskFieldCtrlStub = {
-  index: 'freshdeskFieldCtrl.index',
-  show: 'freshdeskFieldCtrl.show',
-  create: 'freshdeskFieldCtrl.create',
-  update: 'freshdeskFieldCtrl.update',
-  destroy: 'freshdeskFieldCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var freshdeskFieldIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './freshdesk_field.controller': freshdeskFieldCtrlStub
-});
-
-describe('FreshdeskField API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(freshdeskFieldIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/freshdesk/fields', function() {
-
-    it('should route to freshdeskField.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'freshdeskFieldCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/freshdesk/fields/:id', function() {
-
-    it('should route to freshdeskField.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'freshdeskFieldCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/freshdesk/fields', function() {
-
-    it('should route to freshdeskField.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'freshdeskFieldCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/freshdesk/fields/:id', function() {
-
-    it('should route to freshdeskField.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'freshdeskFieldCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/freshdesk/fields/:id', function() {
-
-    it('should route to freshdeskField.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'freshdeskFieldCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/freshdesk/fields/:id', function() {
-
-    it('should route to freshdeskField.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'freshdeskFieldCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/integration/index.js b/server/api/integration/index.js
index 5789126..d2f3bc3 100644
--- a/server/api/integration/index.js
+++ b/server/api/integration/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./integration.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/integration/integration.controller.js b/server/api/integration/integration.controller.js
index fac2b89..48e18a2 100644
--- a/server/api/integration/integration.controller.js
+++ b/server/api/integration/integration.controller.js
@@ -1,179 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var uploadFile = require('upload-file');
-var config = require('../../config/environment');
-var path = require('path');
-var sr = require('simple-random');
-var admZip = require('adm-zip');
-var str2json = require('string-to-json');
-var fs = require('fs');
-
-var Integration = require('../../models').Integration;
-
-// Get list of integrations
-exports.index = function(req, res) {
-  Integration
-    .findAll({
-      where: req.query
-    })
-    .then(function(integrations) {
-      return res.status(200).send(integrations);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single integration
-exports.show = function(req, res) {
-  Integration
-    .findById(req.params.id)
-    .then(function(integration) {
-      if (!integration) {
-        return res.sendStatus(404);
-      }
-      return res.send(integration);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new integration in the DB.
-exports.create = function(req, res) {
-  var upload = new uploadFile({
-    dest: path.join(config.root, 'server/files/integrations'),
-    maxFileSize: 5 * 1000000,
-    maxNumberOfFiles: 1,
-    minNumberOfFiles: 1,
-    acceptFileTypes: /(\.|\/)(zip)$/i,
-    messages: {
-      maxNumberOfFiles: "Max number of files upload exceeded",
-      acceptFileTypes: "Only zip format accepted",
-      maxFileSize: "The maximum file size is 5 Mb",
-      invalidRequest: "Invalid request"
-    }
-  });
-
-  upload.on('end', function(fields, files) {
-    var zip = new admZip(files.file.path);
-
-    var manifest = false;
-    var zipEntries = zip.getEntries();
-    zipEntries.forEach(function(zipEntry) {
-      if (zipEntry.name === 'manifest.json') {
-        var str = zipEntry.getData().toString('utf8');
-        console.log('uploadZip', str);
-        try {
-          manifest = JSON.parse(str);
-          console.log('uploadZip', manifest);
-          Integration
-            .create(_.merge(files.file, manifest))
-            .then(function(integration) {
-
-              // Extract All Zip and overwrite old directory
-              zip.extractAllTo(path.join(config.root,
-                'server/files/integrations'), true);
-
-              return res.status(201).send(integration);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        } catch (e) {
-          console.log(e);
-          var err = {
-            errors: [{
-              type: 'json',
-              message: e
-            }]
-          };
-          return handleError(res, err);
-        }
-      }
-    });
-
-    fs.unlinkSync(files.file.path);
-
-    if (!manifest) {
-      var err = {
-        errors: [{
-          type: 'manifest',
-          message: 'manifest.json not found'
-        }]
-      };
-      return handleError(res, err);
-    }
-  });
-
-  upload.on('error', function(e) {
-    var err = {
-      errors: [{
-        type: 'upload',
-        message: e
-      }]
-    };
-    return handleError(res, err);
-  });
-
-  upload.parse(req);
-};
-
-// Updates an existing integration in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Integration
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(integration) {
-      if (!integration) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(integration, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(integration);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a integration from the DB.
-exports.destroy = function(req, res) {
-  Integration
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(integration) {
-      if (!integration) {
-        return res.sendStatus(404);
-      }
-      integration.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/integration/integration.socket.js b/server/api/integration/integration.socket.js
index a79af43..955e711 100644
--- a/server/api/integration/integration.socket.js
+++ b/server/api/integration/integration.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Integration = require('../../models').Integration;
-
-exports.register = function(socket) {
-  Integration.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Integration.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  Integration.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('integration:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('integration:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/integration/integration.spec.js b/server/api/integration/integration.spec.js
index 0d4146d..8e1d868 100644
--- a/server/api/integration/integration.spec.js
+++ b/server/api/integration/integration.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/integrations', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/integrations')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/interval/index.js b/server/api/interval/index.js
index 2b5572a..c34d745 100644
--- a/server/api/interval/index.js
+++ b/server/api/interval/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./interval.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/all', auth.isAuthenticated(), controller.getAll);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.intervalValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/interval/interval.controller.js b/server/api/interval/interval.controller.js
index e0d975e..3a71e99 100644
--- a/server/api/interval/interval.controller.js
+++ b/server/api/interval/interval.controller.js
@@ -1,324 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Interval = require('../../models').Interval;
-var VoiceExtension = require('../../models').VoiceExtension;
-var sequelize = require('../../models').sequelize;
-var util = require('util');
-
-// Get list of intervals
-exports.index = function(req, res) {
-
-  var attributes = ['name'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {
-      IntervalId: null
-    },
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Interval
-    .findAndCountAll(query)
-    .then(function(intervals) {
-      return res.status(200).send(intervals);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.getAll = function(req, res) {
-  Interval
-    .findAll()
-    .then(function(intervals) {
-      return res.status(200).send(intervals);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// // Get list of subintervals
-// exports.showSubsByInterval = function(req, res) {
-//   VoiceInterval
-//     .findAll({
-//       where: {
-//         VoiceIntervalId: req.params.id
-//       }
-//     })
-//     .then(function(intervals) {
-//       return res.status(200).send(intervals);
-//     })
-//     .catch(function(err) {
-//       return handleError(res, err);
-//     });
-// };
-
-// Get a single interval
-exports.show = function(req, res) {
-  Interval
-    .findById(req.params.id, {
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(interval) {
-      if (!interval) {
-        return res.sendStatus(404);
-      }
-      return res.send(interval);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Validate the existence of a route
-exports.intervalValidation = function(req, res) {
-  var where = {
-    name: req.body.name,
-    IntervalId: req.body.IntervalId ? req.body.IntervalId : null
-  };
-  if (req.body.id) {
-    where.id = {
-      $ne: req.body.id
-    };
-  }
-  console.log(req.body);
-  Interval
-    .findAll({
-      where: where
-    })
-    .then(function(intervals) {
-      if (!intervals) {
-        return res.sendStatus(404);
-      }
-      return res.send(intervals);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new interval in the DB.
-exports.create = function(req, res) {
-  Interval
-    .findAll({
-      where: {
-        name: req.body.name,
-        IntervalId: req.body.IntervalId ? req.body.IntervalId : null
-      }
-    })
-    .then(function(existingIntervals) {
-      console.log(existingIntervals);
-      console.log('Finding app row.....');
-      if (!existingIntervals) {
-        return res.sendStatus(404);
-      }
-      if (existingIntervals.length > 0) {
-        return res.status(500).send({
-          message: req.body.IntervalId ? 'MESSAGE_EXIST_SUBINTERVAL' : 'MESSAGE_EXIST_INTERVAL'
-        });
-      }
-      Interval
-        .create(req.body)
-        .then(function(interval) {
-          return res.status(201).send(interval);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing interval in the DB.
-exports.update = function(req, res) {
-  Interval
-    .findAll({
-      where: {
-        name: req.body.name,
-        IntervalId: req.body.IntervalId ? req.body.IntervalId : null,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function(existingIntervals) {
-      console.log(existingIntervals);
-      console.log('Finding app row.....');
-      if (!existingIntervals) {
-        return res.sendStatus(404);
-      }
-      if (existingIntervals.length > 0) {
-        return res.status(500).send({
-          message: req.body.IntervalId ? 'MESSAGE_EXIST_SUBINTERVAL' : 'MESSAGE_EXIST_INTERVAL'
-        });
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      Interval
-        .find({
-          where: {
-            id: req.params.id
-          }
-        })
-        .then(function(interval) {
-          if (!interval) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(interval, req.body);
-          return sequelize.transaction(function(t) {
-              return updated.save({
-                  transaction: t
-                })
-                .then(function(interval) {
-                  VoiceExtension
-                    .update({
-                      interval: interval.name
-                    }, {
-                      where: {
-                        IntervalId: interval.id
-                      }
-                    }, {
-                      transaction: t
-                    })
-                })
-            })
-            .then(function() {
-              return res.status(200).send(interval);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a interval from the DB.
-exports.destroy = function(req, res) {
-  Interval
-    .findById(req.params.id)
-    .then(function(interval) {
-      if (!interval) {
-        return res.sendStatus(404);
-      }
-      interval.getVoiceExtensions({
-          where: {
-            isApp: true
-          }
-        })
-        .then(function(bindExtensions) {
-          console.log(bindExtensions.length);
-          if (bindExtensions.length > 0) {
-            return res.status(500).send({
-              message: 'MESSAGE_INTERVAL_ROUTE_ASSOCIATED'
-            });
-          }
-          interval.destroy()
-            .then(function() {
-              return res.sendStatus(204);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes multiple intervals from the DB.
-exports.bulkDestroy = function(req, res) {
-  var associatedIntervals = false;
-  Interval
-    .findAll({
-      where: {
-        id: req.query.id
-      },
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(intervals) {
-      if (!intervals) {
-        return res.sendStatus(404);
-      }
-      intervals.forEach(function(element) {
-        if (element.VoiceExtensions.length > 0) {
-          associatedIntervals = true;
-        }
-      });
-      if (associatedIntervals) {
-        return res.status(500).send({
-          message: 'MESSAGE_INTERVAL_ROUTE_ASSOCIATED'
-        });
-      }
-      Interval
-        .destroy({
-          where: {
-            id: req.query.id
-          },
-          individualHooks: true
-        })
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/interval/interval.socket.js b/server/api/interval/interval.socket.js
index d8aee27..7d9acb8 100644
--- a/server/api/interval/interval.socket.js
+++ b/server/api/interval/interval.socket.js
@@ -1,31 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Interval = require('../../models').Interval;
-
-exports.register = function(socket) {
-  Interval.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Interval.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-  Interval.afterUpdate(function(doc) {
-    onUpdate(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('interval:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('interval:remove', doc);
-}
-
-function onUpdate(socket, doc, cb) {
-  socket.emit('interval:update', doc);
-}
\ No newline at end of file
diff --git a/server/api/interval/interval.spec.js b/server/api/interval/interval.spec.js
index 280cb64..dfd73ac 100644
--- a/server/api/interval/interval.spec.js
+++ b/server/api/interval/interval.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/intervals', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/intervals')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/mail_account/index.js b/server/api/mail_account/index.js
index 344873c..8efeee2 100644
--- a/server/api/mail_account/index.js
+++ b/server/api/mail_account/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_account.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-// router.get('/:id/applications', controller.getApplications);
-router.post('/', controller.create);
-router.post('/:id/applications', controller.sortApplications);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/', controller.bulkDestroy);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/mail_account/mail_account.controller.js b/server/api/mail_account/mail_account.controller.js
index 32461ae..b7e8de1 100644
--- a/server/api/mail_account/mail_account.controller.js
+++ b/server/api/mail_account/mail_account.controller.js
@@ -1,291 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var async = require('async');
-
-// IMAP MODULES
-// var Imap = require("mail-listener2");
-// SMTP MODULES
-// var nodemailer = require('nodemailer');
-// var smtpTransport = require('nodemailer-smtp-transport');
-
-var sequelize = require('../../models').sequelize;
-var MailAccount = require('../../models').MailAccount;
-var MailApplication = require('../../models').MailApplication;
-var MailServerIn = require('../../models').MailServerIn;
-var MailServerOut = require('../../models').MailServerOut;
-
-// Get list of mailAccounts
-exports.index = function(req, res) {
-
-  var attributes = ['description', 'name', 'address'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page,
-    include: [{
-      all: true
-    }]
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  MailAccount
-    .findAndCountAll(query)
-    .then(function(result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single mailAccount
-exports.show = function(req, res, next) {
-  MailAccount
-    .findById(req.params.id, {
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(mailAccount) {
-      if (!mailAccount) {
-        return res.sendStatus(404);
-      }
-      return res.send(mailAccount);
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Creates a new mailAccount in the DB.
-exports.create = function(req, res, next) {
-
-  return sequelize.transaction(function(t) {
-
-    // chain all your queries here. make sure you return them.
-    return MailAccount
-      .create({
-        name: req.body.name,
-        address: req.body.address,
-        description: req.body.description
-      }, {
-        transaction: t
-      }).then(function(mailAccount) {
-        // MAIL ACCOUNT ID SETUP
-        req.body.incoming.MailAccountId = mailAccount.id;
-        return MailServerIn
-          .create(req.body.incoming, {
-            transaction: t
-          })
-          .then(function(mailServerIn) {
-            // MAIL ACCOUNT ID SETUP
-            req.body.outgoing.MailAccountId = mailAccount.id;
-            return MailServerOut
-              .create(req.body.outgoing, {
-                transaction: t
-              })
-          });
-      });
-  }).then(function(result) {
-    return res.status(201).send(result);
-  }).catch(function(err) {
-    return next(err);
-  });
-};
-
-// Updates an existing mailAccount in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  MailAccount
-    .findById(req.params.id)
-    .then(function(mailAccount) {
-      if (!mailAccount) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(mailAccount, req.body);
-      updated
-        .save()
-        .then(function() {
-          return res.status(200).send(mailAccount);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Sort Mail Applications
-exports.sortApplications = function(req, res, next) {
-
-  MailApplication
-    .findAll({
-      where: {
-        id: req.body.applications
-      }
-    })
-    .then(function(mailApplications) {
-      var tmpMailApplications = mailApplications;
-
-      async.waterfall([
-        function(callback) {
-          MailApplication
-            .destroy({
-              where: {
-                id: req.body.applications
-              }
-            }).then(function() {
-              console.log('destroy');
-              callback();
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        },
-        function(callback) {
-          // arg1 now equals 'one' and arg2 now equals 'two'
-          var sortedApplications = [];
-          for (var i = 0; i < req.body.applications.length; i++) {
-            var tmpMailApplication = _.find(tmpMailApplications, {
-              'id': req.body.applications[i]
-            });
-            if (tmpMailApplication) {
-              tmpMailApplication.priority = i + 1;
-              sortedApplications.push(tmpMailApplication.dataValues);
-            }
-          }
-
-          MailApplication
-            .bulkCreate(sortedApplications)
-            .then(function() {
-              console.log('bulkCreate');
-              callback();
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        },
-        function(callback) {
-          // arg1 now equals 'three'
-          MailApplication
-            .findAll({
-              where: {
-                id: req.body.applications
-              },
-              order: 'priority',
-              include: [{
-                all: true
-              }]
-            })
-            .then(function(mailApplications) {
-              console.log(mailApplications);
-              callback(null, mailApplications);
-            })
-            .catch(function(err) {
-              callback(err);
-            });
-        }
-      ], function(err, result) {
-        // result now equals 'done'
-        if (err) {
-          return handleError(res, err);
-        } else {
-          return res.status(201).send(result);
-        }
-      });
-
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a mailAccount from the DB.
-exports.destroy = function(req, res, next) {
-  MailAccount
-    .findById(req.params.id)
-    .then(function(mailAccount) {
-      if (!mailAccount) {
-        return res.sendStatus(404);
-      }
-      mailAccount.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return next(err);
-        });
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function(req, res) {
-  MailAccount
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/mail_account/mail_account.socket.js b/server/api/mail_account/mail_account.socket.js
index 5b51c79..6181822 100644
--- a/server/api/mail_account/mail_account.socket.js
+++ b/server/api/mail_account/mail_account.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var MailAccount = require('../../models').MailAccount;
-
-exports.register = function(socket) {
-  MailAccount.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  MailAccount.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  MailAccount.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_account:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_account:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/mail_account/mail_account.spec.js b/server/api/mail_account/mail_account.spec.js
index 80fd2bd..b51fac4 100644
--- a/server/api/mail_account/mail_account.spec.js
+++ b/server/api/mail_account/mail_account.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/mail/accounts', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/mail/accounts')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/mail_application/index.js b/server/api/mail_application/index.js
index 3c132bb..850c40b 100644
--- a/server/api/mail_application/index.js
+++ b/server/api/mail_application/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_application.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/mail_application/mail_application.controller.js b/server/api/mail_application/mail_application.controller.js
index 260557e..a4e8107 100644
--- a/server/api/mail_application/mail_application.controller.js
+++ b/server/api/mail_application/mail_application.controller.js
@@ -1,111 +1 @@
-'use strict';
-var _ = require('lodash');
-var MailApplication = require('../../models').MailApplication;
-// Get list of mailApplications
-exports.index = function(req, res, next) {
-  MailApplication
-    .findAll({
-      where: req.query,
-      order: 'priority',
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(mailApplications) {
-      return res.status(200).send(mailApplications);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-// Get a single mailApplication
-exports.show = function(req, res, next) {
-  MailApplication
-    .findById(req.params.id, {
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(mailApplication) {
-      if (!mailApplication) {
-        return res.sendStatus(404);
-      }
-      return res.send(mailApplication);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-// Creates a new mailApplication in the DB.
-exports.create = function(req, res, next) {
-  MailApplication
-    .max('priority', {
-      where: {
-        MailAccountId: req.body.MailAccountId
-      }
-    }).then(function(max) {
-      // SET PRIORITY
-      req.body.priority = max ? ++max : 1;
-      MailApplication
-        .create(req.body)
-        .then(function(mailApplication) {
-          return res.status(201).send(mailApplication);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-// Updates an existing mailApplication in the DB.
-exports.update = function(req, res, next) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  MailApplication
-    .findById(req.params.id)
-    .then(function(mailApplication) {
-      if (!mailApplication) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(mailApplication, req.body);
-      updated
-        .save()
-        .then(function() {
-          return res.status(200).send(mailApplication);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-// Deletes a mailApplication from the DB.
-exports.destroy = function(req, res, next) {
-  MailApplication
-    .findById(req.params.id)
-    .then(function(mailApplication) {
-      if (!mailApplication) {
-        return res.sendStatus(404);
-      }
-      mailApplication
-        .destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/mail_application/mail_application.socket.js b/server/api/mail_application/mail_application.socket.js
index ead0c90..b46fe54 100644
--- a/server/api/mail_application/mail_application.socket.js
+++ b/server/api/mail_application/mail_application.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var mailApplication = require('../../models').MailApplication;
-
-exports.register = function(socket) {
-  mailApplication.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  mailApplication.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_application:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_application:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/mail_application/mail_application.spec.js b/server/api/mail_application/mail_application.spec.js
index 023b99b..ca78e82 100644
--- a/server/api/mail_application/mail_application.spec.js
+++ b/server/api/mail_application/mail_application.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/mail/applications', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/mail/applications')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/mail_attachment/index.js b/server/api/mail_attachment/index.js
index f154de4..3009f98 100644
--- a/server/api/mail_attachment/index.js
+++ b/server/api/mail_attachment/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_attachment.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/mail_attachment/mail_attachment.controller.js b/server/api/mail_attachment/mail_attachment.controller.js
index f962782..ecf52aa 100644
--- a/server/api/mail_attachment/mail_attachment.controller.js
+++ b/server/api/mail_attachment/mail_attachment.controller.js
@@ -1,87 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var fs = require('fs');
-var MailAttachment = require('../../models').MailAttachment;
-
-// Get list of mailAttachments
-exports.index = function (req, res, next) {
-  MailAttachment
-    .findAll()
-    .then(function (mailAttachments) {
-      return res.status(200).send(mailAttachments);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Get a single mailAttachment
-exports.show = function (req, res, next) {
-  MailAttachment
-    .findById(req.params.id)
-    .then(function (mailAttachment) {
-      res.download(mailAttachment.path, mailAttachment.fileName);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Creates a new mailAttachment in the DB.
-exports.create = function (req, res, next) {
-  MailAttachment
-    .create(req.body)
-    .then(function (mailAttachment) {
-      return res.status(201).send(mailAttachment);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Updates an existing mailAttachment in the DB.
-exports.update = function (req, res, next) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  MailAttachment
-    .findById(req.params.id)
-    .then(function (mailAttachment) {
-      if (!mailAttachment) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(mailAttachment, req.body);
-      updated.save()
-        .then(function () {
-          return res.status(200).send(mailAttachment);
-        })
-        .catch(function (err) {
-          return next(err);
-        });
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Deletes a mailAttachment from the DB.
-exports.destroy = function (req, res, next) {
-  MailAttachment
-    .findById(req.params.id)
-    .then(function (mailAttachment) {
-      if (!mailAttachment) {
-        return res.sendStatus(404);
-      }
-      mailAttachment.destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return next(err);
-        });
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
\ No newline at end of file
diff --git a/server/api/mail_attachment/mail_attachment.socket.js b/server/api/mail_attachment/mail_attachment.socket.js
index 65c9085..bddea3b 100644
--- a/server/api/mail_attachment/mail_attachment.socket.js
+++ b/server/api/mail_attachment/mail_attachment.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var mail_attachment = require('../../models').MailAttachment;
-
-exports.register = function(socket) {
-  mail_attachment.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  mail_attachment.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_attachment:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_attachment:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/mail_attachment/mail_attachment.spec.js b/server/api/mail_attachment/mail_attachment.spec.js
index 026a5dc..916901a 100644
--- a/server/api/mail_attachment/mail_attachment.spec.js
+++ b/server/api/mail_attachment/mail_attachment.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/mail/attachments', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/mail/attachments')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/mail_business_automation/index.js b/server/api/mail_business_automation/index.js
index d8a2dc4..6a8eab7 100644
--- a/server/api/mail_business_automation/index.js
+++ b/server/api/mail_business_automation/index.js
@@ -1,16 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_business_automation.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/', controller.bulkDestroy);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/mail_business_automation/mail_business_automation.controller.js b/server/api/mail_business_automation/mail_business_automation.controller.js
index 5c49502..7d8e320 100644
--- a/server/api/mail_business_automation/mail_business_automation.controller.js
+++ b/server/api/mail_business_automation/mail_business_automation.controller.js
@@ -1,218 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var MailBusinessAutomation = require('../../models').MailBusinessAutomation;
-var BusinessCondition = require('../../models').BusinessCondition;
-var BusinessAction = require('../../models').BusinessAction;
-var sequelize = require('../../models').sequelize;
-
-// Get list of agents
-exports.index = function(req, res, next) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  MailBusinessAutomation
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        mailAutomations: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-// Get a single mailBusinessAutomation
-exports.show = function(req, res) {
-  MailBusinessAutomation
-    .findById(req.params.id, {
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(mailBusinessAutomation) {
-      if (!mailBusinessAutomation) {
-        return res.sendStatus(404);
-      }
-      return res.send(mailBusinessAutomation);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new mailBusinessAutomation in the DB.
-exports.create = function(req, res, next) {
-
-  return sequelize.transaction(function(t) {
-      return MailBusinessAutomation
-        .create(req.body, {
-          transaction: t
-        })
-        .then(function(mailBusinessAutomation) {
-          var conditions = [];
-          if (req.body.or) {
-            req.body.or.forEach(function(elm) {
-              elm.MailBusinessAutomationId = mailBusinessAutomation.id;
-            });
-            conditions = conditions.concat(req.body.or);
-          }
-
-          if (req.body.and) {
-            req.body.and.forEach(function(elm) {
-              elm.MailBusinessAutomationId = mailBusinessAutomation.id;
-            });
-            conditions = conditions.concat(req.body.and);
-          }
-
-          return BusinessCondition
-            .bulkCreate(conditions, {
-              transaction: t
-            })
-            .then(function(businessCondtions) {
-              if (req.body.actions) {
-                req.body.actions.forEach(function(elm) {
-                  elm.MailBusinessAutomationId = mailBusinessAutomation.id;
-                });
-              }
-
-              return BusinessAction
-                .bulkCreate(req.body.actions, {
-                  transaction: t
-                });
-            });
-        })
-    })
-    .then(function() {
-      // Transaction has been committed
-      // result is whatever the result of the promise chain returned to the transaction callback
-      return res.sendStatus(201);
-    }).catch(function(err) {
-      // Transaction has been rolled back
-      // err is whatever rejected the promise chain returned to the transaction callback
-      return next(err);
-    });
-};
-
-// Updates an existing mailBusinessAutomation in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  MailBusinessAutomation
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(mailBusinessAutomation) {
-      if (!mailBusinessAutomation) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(mailBusinessAutomation, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(mailBusinessAutomation);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a mailBusinessAutomation from the DB.
-exports.destroy = function(req, res) {
-  MailBusinessAutomation
-    .findById(req.params.id)
-    .then(function(mailBusinessAutomation) {
-      if (!mailBusinessAutomation) {
-        return res.sendStatus(404);
-      }
-      mailBusinessAutomation
-        .destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function(req, res) {
-  MailBusinessAutomation
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/mail_business_automation/mail_business_automation.socket.js b/server/api/mail_business_automation/mail_business_automation.socket.js
index 0887a18..66ca1dd 100644
--- a/server/api/mail_business_automation/mail_business_automation.socket.js
+++ b/server/api/mail_business_automation/mail_business_automation.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var MailBusinessAutomation = require('../../models').MailBusinessAutomation;
-
-exports.register = function (socket) {
-  MailBusinessAutomation.afterCreate(function (doc, options) {
-    onSave(socket, doc);
-  });
-  MailBusinessAutomation.afterUpdate(function (doc, options) {
-    onSave(socket, doc);
-  });
-  MailBusinessAutomation.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_business_automation:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_business_automation:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/mail_business_automation/mail_business_automation.spec.js b/server/api/mail_business_automation/mail_business_automation.spec.js
index cd29e6c..d51ea46 100644
--- a/server/api/mail_business_automation/mail_business_automation.spec.js
+++ b/server/api/mail_business_automation/mail_business_automation.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/mail/business/automations', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/mail/business/automations')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/mail_message/index.js b/server/api/mail_message/index.js
index fbaf725..0e31e9f 100644
--- a/server/api/mail_message/index.js
+++ b/server/api/mail_message/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_message.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/', auth.isAuthenticated(), controller.update);
-router.put('/delete/bulk', controller.bulkDelete);
-router.put('/delete/:id', controller.update);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/mail_message/mail_message.controller.js b/server/api/mail_message/mail_message.controller.js
index 8687723..f24523c 100644
--- a/server/api/mail_message/mail_message.controller.js
+++ b/server/api/mail_message/mail_message.controller.js
@@ -1,211 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var async = require('async');
-
-var htmlToText = require('html-to-text');
-var formidable = require('formidable');
-var path = require('path');
-
-var config = require('../../config/environment');
-var sequelize = require('../../models').sequelize;
-var MailMessage = require('../../models').MailMessage;
-var MailAttachment = require('../../models').MailAttachment;
-var MailRoom = require('../../models').MailRoom;
-var MailAccount = require('../../models').MailAccount;
-var Contact = require('../../models').Contact;
-
-// Get list of mail_messages
-exports.index = function (req, res, next) {
-  var params = {
-    order: 'createdAt DESC',
-    include: [{
-      all: true,
-      include: [{
-        all: true
-      }]
-    }]
-  };
-
-  switch (req.user.role) {
-  case 'admin':
-    params.where = req.query;
-    break;
-  case 'agent':
-    break;
-  default:
-
-  }
-
-  MailMessage
-    .findAll(params)
-    .then(function (mail_messages) {
-      return res.status(200).send(mail_messages);
-    })
-    .catch(function (err) {
-      return handleError(res, err, next);
-    });
-};
-
-// Get a single mailMessage
-exports.show = function (req, res, next) {
-  MailMessage
-    .findById(req.params.id, {
-      include: [{
-        all: true,
-        include: [{
-          all: true
-        }]
-      }]
-    })
-    .then(function (mailMessage) {
-      if (!mailMessage) {
-        return res.sendStatus(404);
-      }
-      return res.send(mailMessage);
-    })
-    .catch(function (err) {
-      return handleError(res, err, next);
-    });
-};
-
-// Creates a new mailMessage in the DB.
-exports.create = function (req, res, next) {
-  // 1) Messaggio in uscita
-  var form = new formidable.IncomingForm();
-  form.uploadDir = path.join(config.root, 'server', 'files', 'attachments');
-  form.keepExtensions = true;
-  form.multiples = true;
-
-  if (_.isEmpty(req.body)) {
-    // ATTACHMENT
-    form.parse(req, function (err, form, wrap) {
-      if (err) {
-        return res.status(400).send(err);
-      }
-
-      var file = wrap.file;
-      form.MailAttachments = [{
-        path: file.path,
-        fileName: file.name,
-        length: file.size,
-        contentType: file.type
-      }];
-
-      return sequelize.transaction().then(function (t) {
-        return MailMessage
-          .create(form, {
-            include: [{
-              all: true
-            }],
-            transaction: t
-          }).then(function (mailMessage) {
-            t.commit();
-            return res.status(201).send(mailMessage);
-          }).catch(function (err) {
-            t.rollback();
-            return handleError(res, err);
-          });
-      });
-    });
-  } else {
-    // NO ATTACHMENT
-    console.log('NO ATTACHMENT');
-    req.body.status = 'SENDING';
-
-    return sequelize.transaction().then(function (t) {
-      return MailMessage
-        .create(req.body, {
-          transaction: t
-        }).then(function (mailMessage) {
-          t.commit();
-          return res.status(201).send(mailMessage);
-        }).catch(function (err) {
-          t.rollback();
-          return handleError(res, err);
-        });
-    });
-  }
-};
-
-// Updates an existing mailMessage in the DB.
-exports.update = function (req, res, next) {
-
-  MailMessage
-    .findById(req.params.id, {
-      include: [{
-        all: true
-      }]
-    })
-    .then(function (mailMessage) {
-      if (!mailMessage) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(mailMessage, req.body);
-      updated.save()
-        .then(function () {
-          return res.status(200).send(updated);
-        })
-        .catch(function (err) {
-          return handleError(res, err, next);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err, next);
-    });
-};
-
-// Deletes a mailMessage from the DB.
-exports.destroy = function (req, res, next) {
-  MailMessage
-    .findById(req.params.id)
-    .then(function (mailMessage) {
-      if (!mailMessage) {
-        return res.sendStatus(404);
-      }
-      mailMessage.destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return handleError(res, err, next);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err, next);
-    });
-};
-
-// Deletes a mailMessage from the DB.
-exports.bulkDelete = function (req, res, next) {
-  MailMessage
-    .bulkUpdate({
-      where: {
-        id: {
-          $in: req.body.id
-        }
-      },
-      attributes: {
-        directory: 'TRASH'
-      }
-    })
-    .then(function (mailMessage) {
-      if (!mailMessage) {
-        return res.sendStatus(404);
-      }
-      mailMessage.destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return handleError(res, err, next);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err, next);
-    });
-};
-
-function handleError(res, err, next) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/mail_message/mail_message.socket.js b/server/api/mail_message/mail_message.socket.js
index 61eebd5..57cdbe9 100644
--- a/server/api/mail_message/mail_message.socket.js
+++ b/server/api/mail_message/mail_message.socket.js
@@ -1,29 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var MailMessage = require('../../models').MailMessage;
-
-exports.register = function(socket) {
-  MailMessage.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-
-  MailMessage.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-
-  MailMessage.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_message:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_message:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/mail_queue/index.js b/server/api/mail_queue/index.js
index bae067a..ce7d4d4 100644
--- a/server/api/mail_queue/index.js
+++ b/server/api/mail_queue/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_queue.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.post('/:id/agents', controller.addAgents);
-router.put('/:id', controller.update);
-router.put('/:id/agents', controller.removeAgents);
-router.patch('/:id', controller.update);
-router.delete('/', controller.bulkDestroy);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/mail_queue/mail_queue.controller.js b/server/api/mail_queue/mail_queue.controller.js
index a93d548..85d92e2 100644
--- a/server/api/mail_queue/mail_queue.controller.js
+++ b/server/api/mail_queue/mail_queue.controller.js
@@ -1,211 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var MailQueue = require('../../models').MailQueue;
-
-// Get list of mailQueues
-exports.index = function(req, res) {
-
-  var attributes = ['description', 'name', 'timeout', 'strategy'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page,
-    include: [{
-      all: true
-    }]
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  MailQueue
-    .findAndCountAll(query)
-    .then(function(result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single mailQueue
-exports.show = function(req, res) {
-  MailQueue
-    .findById(req.params.id)
-    .then(function(mailQueue) {
-      if (!mailQueue) {
-        return res.sendStatus(404);
-      }
-      return res.send(mailQueue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new mailQueue in the DB.
-exports.create = function(req, res) {
-  MailQueue
-    .create(req.body)
-    .then(function(mailQueue) {
-      return res.status(201).send(mailQueue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing mailQueue in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-
-  MailQueue
-    .findById(req.params.id)
-    .then(function(mailQueue) {
-      if (!mailQueue) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(mailQueue, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(mailQueue);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing user_has_mailQueue in the DB.
-exports.addAgents = function(req, res, next) {
-  return MailQueue
-    .findById(req.params.id)
-    .then(function(mailQueue) {
-      if (mailQueue) {
-        return mailQueue
-          .addUsers(req.body.agents, {
-            individualHooks: true
-          });
-      } else {
-        throw new Error('MailQueue not found');
-      }
-    })
-    .then(function() {
-      return res.sendStatus(200);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.removeAgents = function(req, res) {
-  return MailQueue
-    .findById(req.params.id)
-    .then(function(mailQueue) {
-      if (mailQueue) {
-        return mailQueue
-          .removeUsers(req.body.agents, {
-            individualHooks: true
-          });
-      } else {
-        throw new Error('MailQueue not found');
-      }
-    })
-    .then(function() {
-      return res.sendStatus(200);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a mailQueue from the DB.
-exports.destroy = function(req, res) {
-  MailQueue
-    .findById(req.params.id)
-    .then(function(mailQueue) {
-      if (!mailQueue) {
-        return res.sendStatus(404);
-      }
-      mailQueue
-        .destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function(req, res) {
-  MailQueue
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/mail_queue/mail_queue.socket.js b/server/api/mail_queue/mail_queue.socket.js
index 3518b62..fc715c7 100644
--- a/server/api/mail_queue/mail_queue.socket.js
+++ b/server/api/mail_queue/mail_queue.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var MailQueue = require('../../models').MailQueue;
-
-exports.register = function(socket) {
-  MailQueue.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  MailQueue.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_queue:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_queue:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/mail_queue/mail_queue.spec.js b/server/api/mail_queue/mail_queue.spec.js
index 195e672..fef7696 100644
--- a/server/api/mail_queue/mail_queue.spec.js
+++ b/server/api/mail_queue/mail_queue.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/mail/queues', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/mail/queues')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/mail_room/index.js b/server/api/mail_room/index.js
index c83192a..e521717 100644
--- a/server/api/mail_room/index.js
+++ b/server/api/mail_room/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_room.controller');
-
-var router = express.Router();
-
-// TODO endpoint to filter just NEW/OPEN
-router.get('/', controller.index);
-router.get('/agent/:id', controller.agentIndex);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/', controller.bulkDestroy);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/mail_room/mail_room.controller.js b/server/api/mail_room/mail_room.controller.js
index c82e68d..8bc17d6 100644
--- a/server/api/mail_room/mail_room.controller.js
+++ b/server/api/mail_room/mail_room.controller.js
@@ -1,205 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var User = require('../../models').User;
-var Contact = require('../../models').Contact;
-var MailRoom = require('../../models').MailRoom;
-var MailMessage = require('../../models').MailMessage;
-var MailAccount = require('../../models').MailAccount;
-var MailAttachment = require('../../models').MailAttachment;
-
-// Get list of mailRooms
-exports.index = function (req, res, next) {
-
-  var attributes = ['subject', 'from', 'status'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {
-      status: {
-        $or: ['NEW', 'OPEN']
-      }
-    },
-    limit: per_page,
-    offset: page * per_page,
-    include: [{
-      all: true
-    }]
-  };
-
-  _.forIn(req.query, function (value, key) {
-    switch (key) {
-    case 'per_page':
-    case 'page':
-      break;
-    case 'sort_by':
-      query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-      break;
-    case 'sort_order':
-      break;
-    case '$':
-      query.where.$or = [];
-      attributes.forEach(function (attribute) {
-        var tmp = {};
-        tmp[attribute] = {
-          $like: '%' + value + '%'
-        };
-
-        query.where.$or.push(tmp);
-      });
-      break;
-    default:
-      query.where[key] = {
-        $like: {}
-      };
-      query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-
-  MailRoom
-    .findAndCountAll(query)
-    .then(function (result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        mailRooms: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Get list of agent mailRooms
-exports.agentIndex = function (req, res, next) {
-  MailRoom
-    .findAll({
-      where: {
-        UserId: req.params.id
-      },
-      include: [{
-        all: true
-      }]
-    })
-    .then(function (mailRooms) {
-      return res.status(200).send(mailRooms);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Get a single mailRoom
-exports.show = function (req, res, next) {
-  return MailRoom
-    .findById(req.params.id, {
-      include: [{
-        model: MailMessage,
-        include: [{
-          model: MailRoom,
-          include: [{
-            model: MailAccount
-          }]
-        }, {
-          model: MailAttachment
-        }]
-      }]
-    })
-    .then(function (mailRoom) {
-      if (!mailRoom) {
-        return res.sendStatus(404);
-      }
-
-      return res.send(mailRoom);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Creates a new mailRoom in the DB.
-exports.create = function (req, res, next) {
-  return MailRoom
-    .create(req.body)
-    .then(function (mailRoom) {
-      return res.status(201).send(mailRoom);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing mailRoom in the DB.
-exports.update = function (req, res, next) {
-  return MailRoom
-    .findById(req.params.id)
-    .then(function (mailRoom) {
-      if (!mailRoom) {
-        return res.sendStatus(404);
-      }
-      // CHECK IF MAIL IS ALREADY ASSIGNED
-      if (mailRoom.jobId) {
-        throw new Error('Mail already assigned');
-      }
-      var updated = _.merge(mailRoom, req.body);
-
-      return updated
-        .save();
-    })
-    .then(function (mailRoom) {
-      return res.status(200).send(mailRoom);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a mailRoom from the DB.
-exports.destroy = function (req, res, next) {
-  return MailRoom
-    .findById(req.params.id)
-    .then(function (mailRoom) {
-      if (!mailRoom) {
-        return res.sendStatus(404);
-      }
-      return mailRoom.destroy();
-    })
-    .then(function () {
-      return res.sendStatus(204);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function (req, res) {
-  return MailRoom
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function () {
-      return res.sendStatus(200);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/mail_room/mail_room.socket.js b/server/api/mail_room/mail_room.socket.js
index 4039980..280baf4 100644
--- a/server/api/mail_room/mail_room.socket.js
+++ b/server/api/mail_room/mail_room.socket.js
@@ -1,47 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-
-var MailMessage = require('../../models').MailMessage;
-var MailRoom = require('../../models').MailRoom;
-var User = require('../../models').User;
-
-exports.register = function(socket) {
-  MailRoom.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-
-  MailRoom.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-
-  MailRoom.afterUpdate(function(doc) {
-    MailRoom
-      .findById(doc.id, {
-        include: [{
-          all: true
-        }]
-      })
-      .then(function(mailRoom) {
-        onSave(socket, mailRoom);
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  });
-
-  MailRoom.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_room:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_room:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/mail_server_in/index.js b/server/api/mail_server_in/index.js
index adb146b..e51e842 100644
--- a/server/api/mail_server_in/index.js
+++ b/server/api/mail_server_in/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_server_in.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/mail_server_in/mail_server_in.controller.js b/server/api/mail_server_in/mail_server_in.controller.js
index 4b9bb68..ce7ca6a 100644
--- a/server/api/mail_server_in/mail_server_in.controller.js
+++ b/server/api/mail_server_in/mail_server_in.controller.js
@@ -1,98 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var MailServerIn = require('../../models').MailServerIn;
-
-// Get list of mail_server_ins
-exports.index = function (req, res) {
-  MailServerIn
-    .findAll()
-    .then(function (mail_server_ins) {
-      return res.status(200).send(mail_server_ins);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single mailServerIn
-exports.show = function (req, res) {
-  MailServerIn
-    .findById(req.params.id)
-    .then(function (mailServerIn) {
-      if (!mailServerIn) {
-        return res.sendStatus(404);
-      }
-      return res.send(mailServerIn);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new mailServerIn in the DB.
-exports.create = function (req, res) {
-  MailServerIn
-    .create(req.body)
-    .then(function (mailServerIn) {
-      return res.status(201).send(mailServerIn);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing mailServerIn in the DB.
-exports.update = function (req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  return MailServerIn
-    .findById(req.params.id)
-    .then(function (mailServerIn) {
-      if (!mailServerIn) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(mailServerIn, req.body);
-      updated
-        .save()
-        .then(function () {
-          return res.status(200).send(mailServerIn);
-        })
-        .catch(function (err) {
-          console.error(err);
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      console.error(err);
-      return handleError(res, err);
-    });
-};
-
-// Deletes a mailServerIn from the DB.
-exports.destroy = function (req, res) {
-  MailServerIn
-    .findById(req.params.id)
-    .then(function (mailServerIn) {
-      if (!mailServerIn) {
-        return res.sendStatus(404);
-      }
-      mailServerIn
-        .destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/mail_server_in/mail_server_in.socket.js b/server/api/mail_server_in/mail_server_in.socket.js
index 811977e..25cbac2 100644
--- a/server/api/mail_server_in/mail_server_in.socket.js
+++ b/server/api/mail_server_in/mail_server_in.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var MailServerIn = require('../../models').MailServerIn;
-
-exports.register = function(socket) {
-  MailServerIn.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  MailServerIn.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  MailServerIn.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_server_in:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_server_in:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/mail_server_out/index.js b/server/api/mail_server_out/index.js
index 687b16c..4f78a3a 100644
--- a/server/api/mail_server_out/index.js
+++ b/server/api/mail_server_out/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_server_out.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/service', controller.indexService);
-router.get('/:id', controller.show);
-router.get('/:id/test', controller.test);
-router.post('/', controller.create);
-router.post('/test', controller.test);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/mail_server_out/mail_server_out.controller.js b/server/api/mail_server_out/mail_server_out.controller.js
index 8bcbcb5..512ea91 100644
--- a/server/api/mail_server_out/mail_server_out.controller.js
+++ b/server/api/mail_server_out/mail_server_out.controller.js
@@ -1,165 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var MailServerOut = require('../../models').MailServerOut;
-var MailMessage = require('../../models').MailMessage;
-var sequelize = require('../../models').sequelize;
-
-// Get list of mailServerOuts
-exports.index = function (req, res) {
-  MailServerOut
-    .findAll()
-    .then(function (mailServerOuts) {
-      return res.status(200).send(mailServerOuts);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-exports.indexService = function (req, res) {
-  MailServerOut
-    .findAll({
-      where: {
-        service: true
-      }
-    })
-    .then(function (mailServerOuts) {
-      return res.status(200).send(mailServerOuts);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single mailServerOut
-exports.show = function (req, res) {
-  MailServerOut
-    .findById(req.params.id)
-    .then(function (mailServerOut) {
-      if (!mailServerOut) {
-        return res.sendStatus(404);
-      }
-      return res.send(mailServerOut);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new mailServerOut in the DB.
-exports.create = function (req, res) {
-  MailServerOut
-    .create(req.body)
-    .then(function (mailServerOut) {
-      return res.status(201).send(mailServerOut);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing mailServerOut in the DB.
-exports.update = function (req, res) {
-
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  MailServerOut
-    .findById(req.params.id)
-    .then(function (mailServerOut) {
-      if (!mailServerOut) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(mailServerOut, req.body);
-      updated
-        .save()
-        .then(function () {
-          return res.status(200).send(mailServerOut);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a mailServerOut from the DB.
-exports.destroy = function (req, res) {
-  MailServerOut
-    .findById(req.params.id)
-    .then(function (mailServerOut) {
-      if (!mailServerOut) {
-        return res.sendStatus(404);
-      }
-      mailServerOut
-        .destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-exports.test = function (req, res) {
-  return sequelize.transaction().then(function (t) {
-    var _mailServerOut;
-    var _mailMessage;
-
-    return MailServerOut
-      .findById(req.params.id)
-      .then(function (mailServerOut) {
-        if (!mailServerOut) {
-          t.rollback();
-          return res.sendStatus(404);
-        } else {
-          return mailServerOut;
-        }
-      })
-      .then(function (mailServerOut) {
-        _mailServerOut = mailServerOut;
-        return MailMessage
-          .create({
-            subject: 'MailAccount ' + mailServerOut.username + ' test..',
-            text: 'MailAccount ' + mailServerOut.username + ' test..',
-            from: mailServerOut.username,
-            to: mailServerOut.username,
-            status: 'SENDING'
-          }, {
-            transaction: t
-          });
-      })
-      .then(function (mailMessage) {
-        _mailMessage = mailMessage;
-        return _mailServerOut
-          .update({
-            state: 'CONNECTED',
-          });
-      })
-      .then(function () {
-        t.commit();
-        return res.status(201).send(_mailMessage);
-      })
-      .catch(function (err) {
-        _mailServerOut
-          .update({
-            state: 'ERROR',
-          })
-          .then(function () {
-            t.rollback();
-            return handleError(res, err);
-          })
-      });
-  });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/mail_server_out/mail_server_out.socket.js b/server/api/mail_server_out/mail_server_out.socket.js
index d9e6e91..c025682 100644
--- a/server/api/mail_server_out/mail_server_out.socket.js
+++ b/server/api/mail_server_out/mail_server_out.socket.js
@@ -1,26 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var MailServerOut = require('../../models').MailServerOut;
-
-exports.register = function(socket) {
-  MailServerOut.afterCreate(function(doc) {
-    console.log('MailServerOut afterCreate');
-    onSave(socket, doc);
-  });
-  MailServerOut.afterDestroy(function(doc) {
-    console.log('MailServerOut afterDestroy');
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_server_out:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_server_out:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/mail_template/index.js b/server/api/mail_template/index.js
index cb8e0b2..310546b 100644
--- a/server/api/mail_template/index.js
+++ b/server/api/mail_template/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./mail_template.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/mail_template/mail_template.controller.js b/server/api/mail_template/mail_template.controller.js
index cb8ae52..332aaf2 100644
--- a/server/api/mail_template/mail_template.controller.js
+++ b/server/api/mail_template/mail_template.controller.js
@@ -1,150 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var MailTemplate = require('../../models').MailTemplate;
-
-// Get list of mail_templates
-// Get list of mailQueues
-exports.index = function (req, res) {
-
-  var attributes = ['description', 'name', 'timeout', 'strategy'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page,
-    include: [{
-      all: true
-    }]
-  };
-
-  _.forIn(req.query, function (value, key) {
-    switch (key) {
-    case 'per_page':
-    case 'page':
-      break;
-    case 'sort_by':
-      query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-      break;
-    case 'sort_order':
-      break;
-    case '$':
-      query.where.$or = [];
-      attributes.forEach(function (attribute) {
-        var tmp = {};
-        tmp[attribute] = {
-          $like: '%' + value + '%'
-        };
-
-        query.where.$or.push(tmp);
-      });
-      break;
-    default:
-      query.where[key] = {
-        $like: {}
-      };
-      query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  MailTemplate
-    .findAndCountAll(query)
-    .then(function (result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single mail_template
-exports.show = function (req, res) {
-  MailTemplate
-    .findById(req.params.id)
-    .then(function (mail_template) {
-      if (!mail_template) {
-        return res.sendStatus(404);
-      }
-      return res.send(mail_template);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new mail_template in the DB.
-exports.create = function (req, res) {
-  MailTemplate
-    .create(req.body)
-    .then(function (mail_template) {
-      return res.status(201).send(mail_template);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing mail_template in the DB.
-exports.update = function (req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  MailTemplate
-    .findById(req.params.id)
-    .then(function (mail_template) {
-      if (!mail_template) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(mail_template, req.body);
-      updated.save()
-        .then(function () {
-          return res.status(200).send(mail_template);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a mail_template from the DB.
-exports.destroy = function (req, res) {
-  MailTemplate
-    .findById(req.params.id)
-    .then(function (mail_template) {
-      if (!mail_template) {
-        return res.sendStatus(404);
-      }
-      mail_template.destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/mail_template/mail_template.socket.js b/server/api/mail_template/mail_template.socket.js
index a01fb2e..c57f0a0 100644
--- a/server/api/mail_template/mail_template.socket.js
+++ b/server/api/mail_template/mail_template.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var MailTemplate = require('../../models').MailTemplate;
-
-exports.register = function(socket) {
-  MailTemplate.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  MailTemplate.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('mail_template:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('mail_template:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/metric/index.js b/server/api/metric/index.js
index 41fcceb..f8ec037 100644
--- a/server/api/metric/index.js
+++ b/server/api/metric/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./metric.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.metricValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/metric/metric.controller.js b/server/api/metric/metric.controller.js
index c6ef1d7..e39e282 100644
--- a/server/api/metric/metric.controller.js
+++ b/server/api/metric/metric.controller.js
@@ -1,220 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Metric = require('../../models').Metric;
-var util = require('util');
-
-// Get list of metrics
-exports.index = function(req, res) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Metric
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-exports.metricValidation = function(req, res) {
-  console.log(req.body);
-  Metric
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(metrics) {
-      if (!metrics) {
-        return res.sendStatus(404);
-      }
-      return res.send(metrics);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single metric
-exports.show = function(req, res) {
-  Metric
-    .findById(req.params.id)
-    .then(function(metric) {
-      if (!metric) {
-        return res.sendStatus(404);
-      }
-      return res.send(metric);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new metric in the DB.
-exports.create = function(req, res) {
-  Metric
-    .create(req.body)
-    .then(function(metric) {
-      return res.status(201).send(metric);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing metric in the DB.
-exports.update = function(req, res) {
-  Metric
-    .findAll({
-      where: {
-        name: req.body.name,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function(metrics) {
-      if (!metrics) {
-        return res.sendStatus(404);
-      }
-      if (metrics.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_METRIC'
-        })
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      Metric
-        .find({
-          where: {
-            id: req.params.id
-          }
-        })
-        .then(function(metric) {
-          if (!metric) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(metric, req.body);
-          updated.save()
-            .then(function() {
-              return res.status(200).send(metric);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a metric from the DB.
-exports.destroy = function(req, res) {
-  Metric
-    .findById(req.params.id)
-    .then(function(metric) {
-      if (!metric) {
-        return res.sendStatus(404);
-      }
-      metric.getZendeskTexts()
-        .then(function(texts) {
-          if (texts.length > 0) {
-            return res.status(500).send({
-              message: 'MESSAGE_METRIC_CONFIGURATION_ASSOCIATED'
-            });
-          }
-          metric.destroy()
-            .then(function() {
-              return res.sendStatus(204);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.bulkDestroy = function(req, res) {
-  Metric
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/metric/metric.socket.js b/server/api/metric/metric.socket.js
index 059ce9c..bb92df5 100644
--- a/server/api/metric/metric.socket.js
+++ b/server/api/metric/metric.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Metric = require('../../models').Metric;
-
-exports.register = function(socket) {
-  Metric.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Metric.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('metric:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('metric:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/metric/metric.spec.js b/server/api/metric/metric.spec.js
index 076cab1..bf848ca 100644
--- a/server/api/metric/metric.spec.js
+++ b/server/api/metric/metric.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/analytics/metrics', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/analytics/metrics')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/module/index.js b/server/api/module/index.js
index 8204682..f35304b 100644
--- a/server/api/module/index.js
+++ b/server/api/module/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./module.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/module/module.controller.js b/server/api/module/module.controller.js
index 9d6517c..707bdf7 100644
--- a/server/api/module/module.controller.js
+++ b/server/api/module/module.controller.js
@@ -1,92 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Module = require('../../models').Module;
-
-// Get list of modules
-exports.index = function(req, res) {
-  Module
-  .findAll()
-  .then(function (modules) {
-    return res.status(200).send(modules);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Get a single module
-exports.show = function(req, res) {
-  var moduleId = req.params.id;
-
-  Module
-  .findById(moduleId)
-  .then(function (module) {
-    if(!module) { return res.sendStatus(404); }
-    return res.send(module);
-  })
-  .catch(function(err){
-    return handleError(res, err);
-  });
-};
-
-// Creates a new module in the DB.
-exports.create = function(req, res) {
-  Module
-  .create(req.body)
-  .then(function(module) {
-    return res.status(201).send(module);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Updates an existing module in the DB.
-exports.update = function(req, res) {
-  var moduleId = req.body.id;
-
-  if(req.body.id) { delete req.body.id; }
-
-  Module
-  .findById(moduleId)
-  .then(function (module) {
-    if(!module) { return res.sendStatus(404); }
-    var updated = _.merge(module, req.body);
-    updated.save()
-    .then(function () {
-      return res.status(200).send(module);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Deletes a module from the DB.
-exports.destroy = function(req, res) {
-  var moduleId = req.params.id;
-
-  Module
-  .findById(moduleId)
-  .then(function (module) {
-    if(!module) { return res.sendStatus(404); }
-    module.destroy()
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/module/module.socket.js b/server/api/module/module.socket.js
index 0eade3b..198aca7 100644
--- a/server/api/module/module.socket.js
+++ b/server/api/module/module.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var module = require('../../models').Module;
-
-exports.register = function(socket) {
-  module.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  module.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('module:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('module:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/module/module.spec.js b/server/api/module/module.spec.js
index 45aa629..f4c49a4 100644
--- a/server/api/module/module.spec.js
+++ b/server/api/module/module.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/modules', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/modules')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/module/setting/index.js b/server/api/module/setting/index.js
index f341cb4..6dc6cf0 100644
--- a/server/api/module/setting/index.js
+++ b/server/api/module/setting/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./setting.controller');
-
-var router = express.Router();
-
-// router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/module/setting/setting.controller.js b/server/api/module/setting/setting.controller.js
index 3ebcb5c..0d12611 100644
--- a/server/api/module/setting/setting.controller.js
+++ b/server/api/module/setting/setting.controller.js
@@ -1,110 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var crypto = require('crypto');
-
-var Setting = require('../../models').Setting;
-
-// Get list of settings
-exports.index = function(req, res) {
-  Setting
-    .findAll()
-    .then(function(settings) {
-      return res.status(200).send(settings);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single setting
-exports.show = function(req, res) {
-  Setting
-    .findById(req.params.id)
-    .then(function(setting) {
-      if (!setting) {
-        return res.sendStatus(404);
-      }
-
-      if (setting.license) {
-        setting.license = decrypt('aes-256-ctr', util.format('%s:%s:%s',
-          setting.address, setting.netmask, setting.mac), setting.license);
-        setting.license = JSON.parse(setting.license);
-      }
-
-      return res.send(setting);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new setting in the DB.
-exports.create = function(req, res) {
-  Setting
-    .create(req.body)
-    .then(function(setting) {
-      return res.status(201).send(setting);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing setting in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Setting
-    .findById(req.params.id)
-    .then(function(setting) {
-      if (!setting) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(setting, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(setting);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a setting from the DB.
-exports.destroy = function(req, res) {
-  Setting
-    .findById(req.params.id)
-    .then(function(setting) {
-      if (!setting) {
-        return res.sendStatus(404);
-      }
-      setting.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
-
-function decrypt(algorithm, password, text) {
-  var decipher = crypto.createDecipher(algorithm, password)
-  var dec = decipher.update(text, 'hex', 'utf8')
-  dec += decipher.final('utf8');
-  return dec;
-}
\ No newline at end of file
diff --git a/server/api/module/setting/setting.socket.js b/server/api/module/setting/setting.socket.js
index 0784c1f..ec56b3e 100644
--- a/server/api/module/setting/setting.socket.js
+++ b/server/api/module/setting/setting.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Setting = require('../../models').Setting;
-
-exports.register = function(socket) {
-  Setting.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Setting.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('setting:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('setting:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/module/setting/setting.spec.js b/server/api/module/setting/setting.spec.js
index eec76c9..2881ad9 100644
--- a/server/api/module/setting/setting.spec.js
+++ b/server/api/module/setting/setting.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/settings', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/settings')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/motionbar/index.js b/server/api/motionbar/index.js
index fd9d420..3100bbb 100644
--- a/server/api/motionbar/index.js
+++ b/server/api/motionbar/index.js
@@ -1,11 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./motionbar.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/:action/:state', auth.isAuthenticated(), controller.action);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/motionbar/motionbar.controller.js b/server/api/motionbar/motionbar.controller.js
index f0a79be..d9154c2 100644
--- a/server/api/motionbar/motionbar.controller.js
+++ b/server/api/motionbar/motionbar.controller.js
@@ -1,32 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Motionbar = require('../../models').Motionbar;
-
-// Get list of motionbars
-exports.action = function(req, res) {
-
-  if (!req.query.userId) {
-    return handleError(res, {
-      message: 'Use userId'
-    });
-  }
-
-  req.body.UserId = parseInt(req.query.userId, 10);
-  req.body.action = req.params.action;
-  req.body.state = req.params.state;
-  req.body.AdminId = req.user.id;
-
-  Motionbar
-    .create(req.body)
-    .then(function(action) {
-      return res.status(201).send(action);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/motionbar/motionbar.socket.js b/server/api/motionbar/motionbar.socket.js
index 0eb15d4..7f3ff20 100644
--- a/server/api/motionbar/motionbar.socket.js
+++ b/server/api/motionbar/motionbar.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Motionbar = require('../../models').Motionbar;
-
-exports.register = function(socket) {
-  Motionbar.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Motionbar.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  // doc.UserId is string. You don't use ===
-  if (socket.userId == doc.UserId) {
-    socket.emit('motionbar:save', doc);
-  }
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('motionbar:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/motionbar/motionbar.spec.js b/server/api/motionbar/motionbar.spec.js
index bbbac7f..808097d 100644
--- a/server/api/motionbar/motionbar.spec.js
+++ b/server/api/motionbar/motionbar.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/motionbar', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/motionbar')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/report_agent/index.js b/server/api/report_agent/index.js
index 50a811f..5c5bf59 100644
--- a/server/api/report_agent/index.js
+++ b/server/api/report_agent/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./report_agent.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/report_agent/report_agent.controller.js b/server/api/report_agent/report_agent.controller.js
index 50134d6..480c1f6 100644
--- a/server/api/report_agent/report_agent.controller.js
+++ b/server/api/report_agent/report_agent.controller.js
@@ -1,93 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ReportAgent = require('../../models').ReportAgent;
-
-// Get list of report_agents
-exports.index = function(req, res) {
-  ReportAgent
-    .findAll()
-    .then(function(report_agents) {
-      return res.status(200).send(report_agents);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single report_agent
-exports.show = function(req, res) {
-  ReportAgent
-    .findById(req.params.id)
-    .then(function(report_agent) {
-      if (!report_agent) {
-        return res.sendStatus(404);
-      }
-      return res.send(report_agent);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new report_agent in the DB.
-exports.create = function(req, res) {
-  ReportAgent
-    .create(req.body)
-    .then(function(report_agent) {
-      return res.status(201).send(report_agent);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing report_agent in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ReportAgent
-    .findById(req.params.id)
-    .then(function(report_agent) {
-      if (!report_agent) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(report_agent, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(report_agent);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a report_agent from the DB.
-exports.destroy = function(req, res) {
-  ReportAgent
-    .findById(req.params.id)
-    .then(function(report_agent) {
-      if (!report_agent) {
-        return res.sendStatus(404);
-      }
-      report_agent.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/report_agent/report_agent.socket.js b/server/api/report_agent/report_agent.socket.js
index f6d496d..642a37a 100644
--- a/server/api/report_agent/report_agent.socket.js
+++ b/server/api/report_agent/report_agent.socket.js
@@ -1,50 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ReportAgent = require('../../models').ReportAgent;
-
-exports.register = function(socket) {
-  ReportAgent.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportAgent.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportAgent.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  // socket.emit('report_agent:save', {
-  //   id: doc.id,
-  //   uniqueid: doc.uniqueid,
-  //   calleridnum: doc.callerinum,
-  //   calleridname: doc.calleridname,
-  //   queue: doc.queue,
-  //   interface: doc.interface,
-  //   membername: doc.membername,
-  //   agentcalledAt: doc.agentcalledAt,
-  //   agentconnectAt: doc.agentconnectAt,
-  //   holdtime: doc.holdtime,
-  //   agentcomplete: doc.agentcomplete,
-  //   agentcompleteAt: doc.agentcompleteAt,
-  //   talktime: doc.talktime,
-  //   agentacw: doc.agentacw,
-  //   acwtime: doc.acwtime,
-  //   agentringnoanswer: doc.agentringnoanswer,
-  //   agentringnoanswerAt: doc.agentringnoanswerAt,
-  //   lastevent: doc.lastevent
-  // });
-  if (socket.name === doc.membername || socket.role === 'admin') {
-    socket.emit('report_agent:save', doc);
-  }
-
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('report_agent:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/report_chat/index.js b/server/api/report_chat/index.js
index 6de144c..9d2a740 100644
--- a/server/api/report_chat/index.js
+++ b/server/api/report_chat/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./report_chat.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/report_chat/report_chat.controller.js b/server/api/report_chat/report_chat.controller.js
index d727f82..bf58c93 100644
--- a/server/api/report_chat/report_chat.controller.js
+++ b/server/api/report_chat/report_chat.controller.js
@@ -1,96 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ReportChat = require('../../models').ReportChat;
-var sequelize = require('../../models').sequelize;
-
-// Get list of report_chats
-exports.index = function (req, res) {
-  ReportChat
-    .findAll()
-    .then(function (report_chats) {
-      return res.status(200).send(report_chats);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single reportChat
-exports.show = function (req, res) {
-  ReportChat
-    .findById(req.params.id)
-    .then(function (reportChat) {
-      if (!reportChat) {
-        return res.sendStatus(404);
-      }
-      return res.send(reportChat);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new reportChat in the DB.
-exports.create = function (req, res) {
-  ReportChat
-    .create(req.body)
-    .then(function (reportChat) {
-      return res.status(201).send(reportChat);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing reportChat in the DB.
-exports.update = function (req, res, next) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-
-  return ReportChat
-    .findById(req.params.id)
-    .then(function (reportChat) {
-      if (!reportChat) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(reportChat, req.body);
-      return updated
-        .save()
-        .then(function () {
-          return res.status(200).send(reportChat);
-        });
-    })
-    .catch(sequelize.ValidationError, function (err) {
-      return handleError(res, err);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a reportChat from the DB.
-exports.destroy = function (req, res) {
-  ReportChat
-    .findById(req.params.id)
-    .then(function (reportChat) {
-      if (!reportChat) {
-        return res.sendStatus(404);
-      }
-      reportChat.destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/report_chat/report_chat.socket.js b/server/api/report_chat/report_chat.socket.js
index 21c35bc..74b10b7 100644
--- a/server/api/report_chat/report_chat.socket.js
+++ b/server/api/report_chat/report_chat.socket.js
@@ -1,39 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ReportChat = require('../../models').ReportChat;
-
-exports.register = function (socket) {
-  ReportChat.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  ReportChat.afterUpdate(function (doc) {
-    onUpdate(socket, doc);
-  });
-  ReportChat.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  if (socket.name === doc.membername || socket.role === 'admin') {
-    socket.emit('report_chat:save', doc);
-  }
-}
-
-function onUpdate(socket, doc, cb) {
-  if (socket.name === doc.membername || socket.role === 'admin') {
-    if (doc.changed('agentid')) {
-      socket.emit('report_chat:assignment', doc);
-    } else {
-      socket.emit('report_chat:update', doc);
-    }
-  }
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('report_chat:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/report_chat/report_chat.spec.js b/server/api/report_chat/report_chat.spec.js
index df7a454..e2cd642 100644
--- a/server/api/report_chat/report_chat.spec.js
+++ b/server/api/report_chat/report_chat.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/report/chats', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/report/chats')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/report_chat_session/index.js b/server/api/report_chat_session/index.js
index b302795..b4bb065 100644
--- a/server/api/report_chat_session/index.js
+++ b/server/api/report_chat_session/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./report_chat_session.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/report_chat_session/report_chat_session.controller.js b/server/api/report_chat_session/report_chat_session.controller.js
index 1232f8c..3adc922 100644
--- a/server/api/report_chat_session/report_chat_session.controller.js
+++ b/server/api/report_chat_session/report_chat_session.controller.js
@@ -1,93 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ReportChatSession = require('../../models').ReportChatSession;
-
-// Get list of report_chat_sessions
-exports.index = function(req, res) {
-  ReportChatSession
-  .findAll()
-  .then(function (report_chat_sessions) {
-    return res.status(200).send(report_chat_sessions);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Get a single report_chat_session
-exports.show = function(req, res) {
-  ReportChatSession
-  .findById(req.params.id)
-  .then(function (report_chat_session) {
-    if(!report_chat_session) { return res.sendStatus(404); }
-    return res.send(report_chat_session);
-  })
-  .catch(function(err){
-    return handleError(res, err);
-  });
-};
-
-// Creates a new report_chat_session in the DB.
-exports.create = function(req, res) {
-  ReportChatSession
-  .create(req.body)
-  .then(function(report_chat_session) {
-    return res.status(201).send(report_chat_session);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Updates an existing report_chat_session in the DB.
-exports.update = function(req, res) {
-  if(req.body.id) { delete req.body.id; }
-  ReportChatSession
-  .find({
-    where: {
-      id: req.params.id
-    }
-  })
-  .then(function (report_chat_session) {
-    if(!report_chat_session) { return res.sendStatus(404); }
-    var updated = _.merge(report_chat_session, req.body);
-    updated.save()
-    .then(function () {
-      return res.status(200).send(report_chat_session);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Deletes a report_chat_session from the DB.
-exports.destroy = function(req, res) {
-  ReportChatSession
-  .find({
-    where: {
-      id: req.params.id
-    }
-  })
-  .then(function (report_chat_session) {
-    if(!report_chat_session) { return res.sendStatus(404); }
-    report_chat_session.destroy()
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/report_chat_session/report_chat_session.socket.js b/server/api/report_chat_session/report_chat_session.socket.js
index a378e10..806ad85 100644
--- a/server/api/report_chat_session/report_chat_session.socket.js
+++ b/server/api/report_chat_session/report_chat_session.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ReportChatSession = require('../../models').ReportChatSession;
-
-exports.register = function(socket) {
-  ReportChatSession.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportChatSession.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportChatSession.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('report_chat_session:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('report_chat_session:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/report_chat_session/report_chat_session.spec.js b/server/api/report_chat_session/report_chat_session.spec.js
index f58cff0..10f0b43 100644
--- a/server/api/report_chat_session/report_chat_session.spec.js
+++ b/server/api/report_chat_session/report_chat_session.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/report/chat/sessions', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/report/chat/sessions')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/report_integration/index.js b/server/api/report_integration/index.js
index 3485189..6d97da0 100644
--- a/server/api/report_integration/index.js
+++ b/server/api/report_integration/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./report_integration.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/report_integration/report_integration.controller.js b/server/api/report_integration/report_integration.controller.js
index 345115e..7100234 100644
--- a/server/api/report_integration/report_integration.controller.js
+++ b/server/api/report_integration/report_integration.controller.js
@@ -1,93 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ReportIntegration = require('../../models').ReportIntegration;
-
-// Get list of report_integrations
-exports.index = function(req, res) {
-  ReportIntegration
-    .findAll()
-    .then(function(report_integrations) {
-      return res.status(200).send(report_integrations);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single report_integration
-exports.show = function(req, res) {
-  ReportIntegration
-    .findById(req.params.id)
-    .then(function(report_integration) {
-      if (!report_integration) {
-        return res.sendStatus(404);
-      }
-      return res.send(report_integration);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new report_integration in the DB.
-exports.create = function(req, res) {
-  ReportIntegration
-    .create(req.body)
-    .then(function(report_integration) {
-      return res.status(201).send(report_integration);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing report_integration in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ReportIntegration
-    .findById(req.params.id)
-    .then(function(report_integration) {
-      if (!report_integration) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(report_integration, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(report_integration);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a report_integration from the DB.
-exports.destroy = function(req, res) {
-  ReportIntegration
-    .findById(req.params.id)
-    .then(function(report_integration) {
-      if (!report_integration) {
-        return res.sendStatus(404);
-      }
-      report_integration.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/report_integration/report_integration.socket.js b/server/api/report_integration/report_integration.socket.js
index dd557b8..9671e44 100644
--- a/server/api/report_integration/report_integration.socket.js
+++ b/server/api/report_integration/report_integration.socket.js
@@ -1,20 +1 @@
-/**
- * Broadcast integrations update when the model changes
- */
-
-'use strict';
-
-var util = require('util');
-var ReportIntegration = require('../../models').ReportIntegration;
-
-exports.register = function(socket) {
-  ReportIntegration.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  if (socket.name === doc.membername) {
-    socket.emit(util.format('report_integration:%s', doc.integration), doc);
-  }
-}
\ No newline at end of file
diff --git a/server/api/report_mail/index.js b/server/api/report_mail/index.js
index c895f2a..fb1f089 100644
--- a/server/api/report_mail/index.js
+++ b/server/api/report_mail/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./report_mail.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/report_mail/report_mail.controller.js b/server/api/report_mail/report_mail.controller.js
index ccc28b5..03c8972 100644
--- a/server/api/report_mail/report_mail.controller.js
+++ b/server/api/report_mail/report_mail.controller.js
@@ -1,93 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ReportMail = require('../../models').ReportMail;
-
-// Get list of report_mails
-exports.index = function(req, res) {
-  ReportMail
-    .findAll()
-    .then(function(report_mails) {
-      return res.status(200).send(report_mails);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single reportMail
-exports.show = function(req, res) {
-  ReportMail
-    .findById(req.params.id)
-    .then(function(reportMail) {
-      if (!reportMail) {
-        return res.sendStatus(404);
-      }
-      return res.send(reportMail);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new reportMail in the DB.
-exports.create = function(req, res) {
-  ReportMail
-    .create(req.body)
-    .then(function(reportMail) {
-      return res.status(201).send(reportMail);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing reportMail in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ReportMail
-    .findById(req.params.id)
-    .then(function(reportMail) {
-      if (!reportMail) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(reportMail, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(reportMail);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a reportMail from the DB.
-exports.destroy = function(req, res) {
-  ReportMail
-    .findById(req.params.id)
-    .then(function(reportMail) {
-      if (!reportMail) {
-        return res.sendStatus(404);
-      }
-      reportMail.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/report_mail/report_mail.socket.js b/server/api/report_mail/report_mail.socket.js
index 1fec069..523c8dc 100644
--- a/server/api/report_mail/report_mail.socket.js
+++ b/server/api/report_mail/report_mail.socket.js
@@ -1,35 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ReportMail = require('../../models').ReportMail;
-
-exports.register = function(socket) {
-  ReportMail.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportMail.afterUpdate(function(doc) {
-    onUpdate(socket, doc);
-  });
-  ReportMail.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  if (socket.name === doc.membername || socket.role === 'admin') {
-    socket.emit('report_mail:save', doc);
-  }
-}
-
-function onUpdate(socket, doc, cb) {
-  if (socket.name === doc.membername || socket.role === 'admin') {
-    socket.emit('report_mail:update', doc);
-  }
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('report_mail:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/report_mail/report_mail.spec.js b/server/api/report_mail/report_mail.spec.js
index 80e5153..c5bec13 100644
--- a/server/api/report_mail/report_mail.spec.js
+++ b/server/api/report_mail/report_mail.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/report/mails', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/report/mails')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/report_mail_session/index.js b/server/api/report_mail_session/index.js
index ecd3edc..e808c30 100644
--- a/server/api/report_mail_session/index.js
+++ b/server/api/report_mail_session/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./report_mail_session.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/report_mail_session/report_mail_session.controller.js b/server/api/report_mail_session/report_mail_session.controller.js
index d218fae..515787f 100644
--- a/server/api/report_mail_session/report_mail_session.controller.js
+++ b/server/api/report_mail_session/report_mail_session.controller.js
@@ -1,93 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ReportMailSession = require('../../models').ReportMailSession;
-
-// Get list of report_mail_sessions
-exports.index = function(req, res) {
-  ReportMailSession
-  .findAll()
-  .then(function (report_mail_sessions) {
-    return res.status(200).send(report_mail_sessions);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Get a single report_mail_session
-exports.show = function(req, res) {
-  ReportMailSession
-  .findById(req.params.id)
-  .then(function (report_mail_session) {
-    if(!report_mail_session) { return res.sendStatus(404); }
-    return res.send(report_mail_session);
-  })
-  .catch(function(err){
-    return handleError(res, err);
-  });
-};
-
-// Creates a new report_mail_session in the DB.
-exports.create = function(req, res) {
-  ReportMailSession
-  .create(req.body)
-  .then(function(report_mail_session) {
-    return res.status(201).send(report_mail_session);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Updates an existing report_mail_session in the DB.
-exports.update = function(req, res) {
-  if(req.body.id) { delete req.body.id; }
-  ReportMailSession
-  .find({
-    where: {
-      id: req.params.id
-    }
-  })
-  .then(function (report_mail_session) {
-    if(!report_mail_session) { return res.sendStatus(404); }
-    var updated = _.merge(report_mail_session, req.body);
-    updated.save()
-    .then(function () {
-      return res.status(200).send(report_mail_session);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Deletes a report_mail_session from the DB.
-exports.destroy = function(req, res) {
-  ReportMailSession
-  .find({
-    where: {
-      id: req.params.id
-    }
-  })
-  .then(function (report_mail_session) {
-    if(!report_mail_session) { return res.sendStatus(404); }
-    report_mail_session.destroy()
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/report_mail_session/report_mail_session.socket.js b/server/api/report_mail_session/report_mail_session.socket.js
index 6489a0d..4042787 100644
--- a/server/api/report_mail_session/report_mail_session.socket.js
+++ b/server/api/report_mail_session/report_mail_session.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ReportMailSession = require('../../models').ReportMailSession;
-
-exports.register = function(socket) {
-  ReportMailSession.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportMailSession.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportMailSession.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('report_mail_session:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('report_mail_session:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/report_mail_session/report_mail_session.spec.js b/server/api/report_mail_session/report_mail_session.spec.js
index d528b0c..31fc9a5 100644
--- a/server/api/report_mail_session/report_mail_session.spec.js
+++ b/server/api/report_mail_session/report_mail_session.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/report/mail/sessions', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/report/mail/sessions')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/report_queue/index.js b/server/api/report_queue/index.js
index 613730a..7bd3db6 100644
--- a/server/api/report_queue/index.js
+++ b/server/api/report_queue/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./report_queue.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/report_queue/report_queue.controller.js b/server/api/report_queue/report_queue.controller.js
index 2d7ce21..00e9d39 100644
--- a/server/api/report_queue/report_queue.controller.js
+++ b/server/api/report_queue/report_queue.controller.js
@@ -1,93 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ReportQueue = require('../../models').ReportQueue;
-
-// Get list of report_queues
-exports.index = function(req, res) {
-  ReportQueue
-    .findAll()
-    .then(function(report_queues) {
-      return res.status(200).send(report_queues);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single report_queue
-exports.show = function(req, res) {
-  ReportQueue
-    .findById(req.params.id)
-    .then(function(report_queue) {
-      if (!report_queue) {
-        return res.sendStatus(404);
-      }
-      return res.send(report_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new report_queue in the DB.
-exports.create = function(req, res) {
-  ReportQueue
-    .create(req.body)
-    .then(function(report_queue) {
-      return res.status(201).send(report_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing report_queue in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ReportQueue
-    .findById(req.params.id)
-    .then(function(report_queue) {
-      if (!report_queue) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(report_queue, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(report_queue);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a report_queue from the DB.
-exports.destroy = function(req, res) {
-  ReportQueue
-    .findById(req.params.id)
-    .then(function(report_queue) {
-      if (!report_queue) {
-        return res.sendStatus(404);
-      }
-      report_queue.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/report_queue/report_queue.socket.js b/server/api/report_queue/report_queue.socket.js
index 9f57869..c73c0b5 100644
--- a/server/api/report_queue/report_queue.socket.js
+++ b/server/api/report_queue/report_queue.socket.js
@@ -1,29 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ReportQueue = require('../../models').ReportQueue;
-
-exports.register = function(socket) {
-  ReportQueue.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportQueue.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportQueue.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  if (socket.role === 'admin') {
-    socket.emit('report_queue:save', doc);
-  }
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('report_queue:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/report_tree/index.js b/server/api/report_tree/index.js
index 75fa91c..db9419b 100644
--- a/server/api/report_tree/index.js
+++ b/server/api/report_tree/index.js
@@ -1,12 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./report_tree.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/report_tree/report_tree.controller.js b/server/api/report_tree/report_tree.controller.js
index a6b11b0..4ac8adc 100644
--- a/server/api/report_tree/report_tree.controller.js
+++ b/server/api/report_tree/report_tree.controller.js
@@ -1,46 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var ReportTree = require('../../models').ReportTree;
-
-// Get the reports trees
-exports.index = function(req, res) {
-  ReportTree
-    .findAll()
-    .then(function(trees) {
-      if (!trees) {
-        return res.sendStatus(404);
-      }
-      return res.status(200).send(trees);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing report in the DB.
-exports.update = function(req, res) {
-  ReportTree
-    .findById(req.params.id)
-    .then(function(tree) {
-      if (!tree) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(tree, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(tree);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/report_tree/report_tree.socket.js b/server/api/report_tree/report_tree.socket.js
index 389fa7a..07e82ed 100644
--- a/server/api/report_tree/report_tree.socket.js
+++ b/server/api/report_tree/report_tree.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ReportTree = require('../../models').ReportTree;
-
-exports.register = function(socket) {
-  ReportTree.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportTree.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  ReportTree.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('report_tree:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('report_tree:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/report_tree/report_tree.spec.js b/server/api/report_tree/report_tree.spec.js
index 37d897a..47203c0 100644
--- a/server/api/report_tree/report_tree.spec.js
+++ b/server/api/report_tree/report_tree.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/analytics/reports/trees', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/analytic/reports/trees')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/salesforce_account/index.js b/server/api/salesforce_account/index.js
index d8b47b0..144e23f 100644
--- a/server/api/salesforce_account/index.js
+++ b/server/api/salesforce_account/index.js
@@ -1,21 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./salesforce_account.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount);
-router.get('/:id/fields', auth.isAuthenticated(), controller.getFields);
-router.post('/validate/:field', auth.isAuthenticated(), controller.accountValidation);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/salesforce_account/index.spec.js b/server/api/salesforce_account/index.spec.js
index a03b303..5e1e213 100644
--- a/server/api/salesforce_account/index.spec.js
+++ b/server/api/salesforce_account/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var salesforceAccountCtrlStub = {
-  index: 'salesforceAccountCtrl.index',
-  show: 'salesforceAccountCtrl.show',
-  create: 'salesforceAccountCtrl.create',
-  update: 'salesforceAccountCtrl.update',
-  destroy: 'salesforceAccountCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var salesforceAccountIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './salesforce_account.controller': salesforceAccountCtrlStub
-});
-
-describe('SalesforceAccount API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(salesforceAccountIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/salesforce/accounts', function() {
-
-    it('should route to salesforceAccount.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'salesforceAccountCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/salesforce/accounts/:id', function() {
-
-    it('should route to salesforceAccount.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'salesforceAccountCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/salesforce/accounts', function() {
-
-    it('should route to salesforceAccount.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'salesforceAccountCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/salesforce/accounts/:id', function() {
-
-    it('should route to salesforceAccount.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'salesforceAccountCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/salesforce/accounts/:id', function() {
-
-    it('should route to salesforceAccount.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'salesforceAccountCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/salesforce/accounts/:id', function() {
-
-    it('should route to salesforceAccount.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'salesforceAccountCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/salesforce_account/salesforce_account.controller.js b/server/api/salesforce_account/salesforce_account.controller.js
index 69c55e6..1b9122b 100644
--- a/server/api/salesforce_account/salesforce_account.controller.js
+++ b/server/api/salesforce_account/salesforce_account.controller.js
@@ -1,253 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/salesforce/accounts              ->  index
- * POST    /api/salesforce/accounts              ->  create
- * GET     /api/salesforce/accounts/:id          ->  show
- * PUT     /api/salesforce/accounts/:id          ->  update
- * DELETE  /api/salesforce/accounts/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-var util = require('util');
-var jsforce = require('jsforce');
-
-var SalesforceAccount = require('../../models').SalesforceAccount;
-
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of SalesforceAccounts
-exports.index = function(req, res) {
-  var attributes = ['description', 'name', 'username', 'remoteUri'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  SalesforceAccount
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      return res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-}
-
-// Gets a single SalesforceAccount from the DB
-exports.show = function(req, res) {
-  SalesforceAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new SalesforceAccount in the DB
-exports.create = function(req, res) {
-  SalesforceAccount.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing SalesforceAccount in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  SalesforceAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a SalesforceAccount from the DB
-exports.destroy = function(req, res) {
-  SalesforceAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
-
-exports.checkAccount = function(req, res) {
-  SalesforceAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(account) {
-      var conn = new jsforce.Connection({
-        oauth2: {
-          loginUrl: account.remoteUri,
-          clientId: account.clientId,
-          clientSecret: account.clientSecret,
-        }
-      });
-      var pwd = account.password.concat(account.securityToken);
-      conn.login(account.username, pwd, function(err, userInfo) {
-        if (err) {
-          return res.status(400).send(err);
-        }
-        return res.sendStatus(200);
-      });
-    })
-    .catch(handleError(res));
-}
-
-exports.accountValidation = function(req, res) {
-  var where = {};
-  where[req.params.field] = req.body.value;
-  SalesforceAccount
-    .findAndCountAll({
-      where: where
-    })
-    .then(function(result) {
-      if (result.count) {
-        return res.status(200).send({
-          isValid: false,
-          value: req.body.value
-        });
-      }
-      return res.status(200).send({
-        isValid: true,
-        value: req.body.value
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.getFields = function(req, res) {
-  SalesforceAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(account) {
-      var conn = new jsforce.Connection({
-        oauth2: {
-          loginUrl: account.remoteUri,
-          clientId: account.clientId,
-          clientSecret: account.clientSecret,
-        }
-      });
-      var pwd = account.password.concat(account.securityToken);
-      conn.login(account.username, pwd, function(err, userInfo) {
-        if (err) {
-          return res.status(400).send(err);
-        }
-        conn.sobject("Task").describe(function(err, meta) {
-          if (err) {
-            return res.status(400).send(err);
-          }
-          return res.status(200).send(meta.fields);
-        });
-      });
-    })
-    .catch(handleError(res));
-};
-
-exports.bulkDestroy = function(req, res) {
-  SalesforceAccount
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
\ No newline at end of file
diff --git a/server/api/salesforce_account/salesforce_account.socket.js b/server/api/salesforce_account/salesforce_account.socket.js
index 2c58d15..9c7a995 100644
--- a/server/api/salesforce_account/salesforce_account.socket.js
+++ b/server/api/salesforce_account/salesforce_account.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var SalesforceAccount = require('../../models').SalesforceAccount;
-
-exports.register = function(socket) {
-  SalesforceAccount.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  SalesforceAccount.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('salesforce_account:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('salesforce_account:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/salesforce_configuration/index.js b/server/api/salesforce_configuration/index.js
index 7936a09..f0fbfcf 100644
--- a/server/api/salesforce_configuration/index.js
+++ b/server/api/salesforce_configuration/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./salesforce_configuration.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/salesforce_configuration/index.spec.js b/server/api/salesforce_configuration/index.spec.js
index 0d1e211..2eeb54b 100644
--- a/server/api/salesforce_configuration/index.spec.js
+++ b/server/api/salesforce_configuration/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var salesforceConfigurationCtrlStub = {
-  index: 'salesforceConfigurationCtrl.index',
-  show: 'salesforceConfigurationCtrl.show',
-  create: 'salesforceConfigurationCtrl.create',
-  update: 'salesforceConfigurationCtrl.update',
-  destroy: 'salesforceConfigurationCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var salesforceConfigurationIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './salesforce_configuration.controller': salesforceConfigurationCtrlStub
-});
-
-describe('SalesforceConfiguration API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(salesforceConfigurationIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/salesforce/configurations', function() {
-
-    it('should route to salesforceConfiguration.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'salesforceConfigurationCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/salesforce/configurations/:id', function() {
-
-    it('should route to salesforceConfiguration.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'salesforceConfigurationCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/salesforce/configurations', function() {
-
-    it('should route to salesforceConfiguration.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'salesforceConfigurationCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/salesforce/configurations/:id', function() {
-
-    it('should route to salesforceConfiguration.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'salesforceConfigurationCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/salesforce/configurations/:id', function() {
-
-    it('should route to salesforceConfiguration.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'salesforceConfigurationCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/salesforce/configurations/:id', function() {
-
-    it('should route to salesforceConfiguration.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'salesforceConfigurationCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/salesforce_configuration/salesforce_configuration.controller.js b/server/api/salesforce_configuration/salesforce_configuration.controller.js
index 523aef6..46304ed 100644
--- a/server/api/salesforce_configuration/salesforce_configuration.controller.js
+++ b/server/api/salesforce_configuration/salesforce_configuration.controller.js
@@ -1,147 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/salesforce/configurations              ->  index
- * POST    /api/salesforce/configurations              ->  create
- * GET     /api/salesforce/configurations/:id          ->  show
- * PUT     /api/salesforce/configurations/:id          ->  update
- * DELETE  /api/salesforce/configurations/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-
-var SalesforceConfiguration = require('../../models').SalesforceConfiguration;
-var SalesforceField = require('../../models').SalesforceField;
-
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of SalesforceConfigurations
-exports.index = function(req, res) {
-  SalesforceConfiguration.findAll({
-      where: req.query
-    })
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Gets a single SalesforceConfiguration from the DB
-exports.show = function(req, res) {
-  SalesforceConfiguration.find({
-      where: {
-        id: req.params.id
-      },
-      include: [{
-        model: SalesforceField,
-        as: 'Subject'
-      }, {
-        model: SalesforceField,
-        as: 'Description'
-      }, {
-        model: SalesforceField,
-        as: 'Field'
-      }]
-    })
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new SalesforceConfiguration in the DB
-exports.create = function(req, res) {
-  SalesforceConfiguration.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing SalesforceConfiguration in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  SalesforceConfiguration.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a SalesforceConfiguration from the DB
-exports.destroy = function(req, res) {
-  SalesforceConfiguration.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
-
-exports.addConfigurationField = function(req, res, next) {
-  // console.log(req.params);
-  var salesforceConfiguration;
-  SalesforceConfiguration
-    .findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(salesforce_configuration) {
-      salesforceConfiguration = salesforce_configuration;
-      return SalesforceField.create(req.body)
-    })
-    .then(function(salesforceField) {
-      switch (req.params.type) {
-        case 'subject':
-          return [salesforceConfiguration.addSubject(salesforceField), salesforceField];
-        case 'description':
-          return [salesforceConfiguration.addDescription(salesforceField), salesforceField];
-        case 'field':
-          return [salesforceConfiguration.addField(salesforceField), salesforceField];
-      }
-    })
-    .spread(function(data, salesforceField) {
-      return res.status(201).json(salesforceField);
-    })
-    .catch(handleError(res));
-};
\ No newline at end of file
diff --git a/server/api/salesforce_configuration/salesforce_configuration.socket.js b/server/api/salesforce_configuration/salesforce_configuration.socket.js
index c45a482..dc0b677 100644
--- a/server/api/salesforce_configuration/salesforce_configuration.socket.js
+++ b/server/api/salesforce_configuration/salesforce_configuration.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var SalesforceConfiguration = require('../../models').SalesforceConfiguration;
-
-exports.register = function(socket) {
-  SalesforceConfiguration.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  SalesforceConfiguration.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('salesforce_configuration:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('salesforce_configuration:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/salesforce_field/index.js b/server/api/salesforce_field/index.js
index 4a0ccb2..a358ab6 100644
--- a/server/api/salesforce_field/index.js
+++ b/server/api/salesforce_field/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./salesforce_field.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/salesforce_field/index.spec.js b/server/api/salesforce_field/index.spec.js
index 639e318..9dafd56 100644
--- a/server/api/salesforce_field/index.spec.js
+++ b/server/api/salesforce_field/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var salesforceFieldCtrlStub = {
-  index: 'salesforceFieldCtrl.index',
-  show: 'salesforceFieldCtrl.show',
-  create: 'salesforceFieldCtrl.create',
-  update: 'salesforceFieldCtrl.update',
-  destroy: 'salesforceFieldCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var salesforceFieldIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './salesforce_field.controller': salesforceFieldCtrlStub
-});
-
-describe('SalesforceField API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(salesforceFieldIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/salesforce/fields', function() {
-
-    it('should route to salesforceField.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'salesforceFieldCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/salesforce/fields/:id', function() {
-
-    it('should route to salesforceField.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'salesforceFieldCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/salesforce/fields', function() {
-
-    it('should route to salesforceField.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'salesforceFieldCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/salesforce/fields/:id', function() {
-
-    it('should route to salesforceField.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'salesforceFieldCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/salesforce/fields/:id', function() {
-
-    it('should route to salesforceField.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'salesforceFieldCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/salesforce/fields/:id', function() {
-
-    it('should route to salesforceField.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'salesforceFieldCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/salesforce_field/salesforce_field.controller.js b/server/api/salesforce_field/salesforce_field.controller.js
index bab61d7..ef06633 100644
--- a/server/api/salesforce_field/salesforce_field.controller.js
+++ b/server/api/salesforce_field/salesforce_field.controller.js
@@ -1,104 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/salesforce/fields              ->  index
- * POST    /api/salesforce/fields              ->  create
- * GET     /api/salesforce/fields/:id          ->  show
- * PUT     /api/salesforce/fields/:id          ->  update
- * DELETE  /api/salesforce/fields/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-
-var SalesforceField = require('../../models').SalesforceField;
-
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of SalesforceFields
-exports.index = function(req, res) {
-  SalesforceField.findAll()
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Gets a single SalesforceField from the DB
-exports.show = function(req, res) {
-  SalesforceField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new SalesforceField in the DB
-exports.create = function(req, res) {
-  SalesforceField.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing SalesforceField in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  SalesforceField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a SalesforceField from the DB
-exports.destroy = function(req, res) {
-  SalesforceField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
\ No newline at end of file
diff --git a/server/api/salesforce_field/salesforce_field.socket.js b/server/api/salesforce_field/salesforce_field.socket.js
index b3f5775..4fb61ef 100644
--- a/server/api/salesforce_field/salesforce_field.socket.js
+++ b/server/api/salesforce_field/salesforce_field.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var SalesforceField = require('../../models').SalesforceField;
-
-exports.register = function(socket) {
-  SalesforceField.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  SalesforceField.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('salesforce_field:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('salesforce_field:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/setting/index.js b/server/api/setting/index.js
index d39a451..4578edd 100644
--- a/server/api/setting/index.js
+++ b/server/api/setting/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./setting.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/internal', auth.isAuthenticated(), controller.getInternal);
-router.get('/info', controller.getInfo);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/setting/setting.controller.js b/server/api/setting/setting.controller.js
index 4cbb858..8e7cdff 100644
--- a/server/api/setting/setting.controller.js
+++ b/server/api/setting/setting.controller.js
@@ -1,152 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Settings = require('../../models').Settings;
-var Agent = require('../../models').User;
-
-// Get list of settings
-exports.index = function(req, res) {
-  Settings
-    .findAll()
-    .then(function(settings) {
-      return res.status(200).send(settings);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get list of settings
-exports.getInternal = function(req, res) {
-  Settings
-    .findOne()
-    .then(function(result) {
-      Agent
-        .findAll({
-          where: {
-            internal: {
-              $gte: result.min_internal
-            }
-          }
-        })
-        .then(function(internals) {
-          var pluckdInternals = _.pluck(_.pluck(internals, 'dataValues'), 'internal');
-          var lastChecked = result.min_internal;
-          var internalNumber = {
-            value: null
-          };
-          do {
-            if (pluckdInternals.indexOf(lastChecked) === -1) {
-              internalNumber.value = lastChecked;
-            } else {
-              lastChecked++;
-            }
-          } while (!internalNumber.value)
-          return res.status(200).send(internalNumber);
-        })
-        .catch(function(err) {
-          console.log(err);
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get list of settings
-exports.getInfo = function(req, res) {
-
-  var info = require('../../../package.json');
-
-  return res.status(200).send({
-    name: info.name,
-    version: info.version,
-    engines: info.engines
-  });
-};
-
-// Get a single setting
-exports.show = function(req, res) {
-  Settings
-    .findById(req.params.id)
-    .then(function(setting) {
-      if (!setting) {
-        return res.sendStatus(404);
-      }
-      return res.send(setting);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new setting in the DB.
-exports.create = function(req, res) {
-  Settings
-    .create(req.body)
-    .then(function(setting) {
-      return res.status(201).send(setting);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing setting in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Settings
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(setting) {
-      if (!setting) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(setting, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(setting);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a setting from the DB.
-exports.destroy = function(req, res) {
-  Settings
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(setting) {
-      if (!setting) {
-        return res.sendStatus(404);
-      }
-      setting.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/setting/setting.socket.js b/server/api/setting/setting.socket.js
index 611827e..40b29c7 100644
--- a/server/api/setting/setting.socket.js
+++ b/server/api/setting/setting.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Settings = require('../../models').Settings;
-
-exports.register = function(socket) {
-  Settings.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Settings.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('setting:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('setting:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/setting/setting.spec.js b/server/api/setting/setting.spec.js
index eec76c9..9952cdc 100644
--- a/server/api/setting/setting.spec.js
+++ b/server/api/setting/setting.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/settings', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/settings')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/square_odbc/index.js b/server/api/square_odbc/index.js
index 9d53bf8..5b86f05 100644
--- a/server/api/square_odbc/index.js
+++ b/server/api/square_odbc/index.js
@@ -1,17 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./square_odbc.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.odbcValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/square_odbc/square_odbc.controller.js b/server/api/square_odbc/square_odbc.controller.js
index a444b26..4e8e764 100644
--- a/server/api/square_odbc/square_odbc.controller.js
+++ b/server/api/square_odbc/square_odbc.controller.js
@@ -1,209 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var SquareOdbc = require('../../models').SquareOdbc;
-var util = require('util');
-
-// Get list of square_odbcs
-exports.index = function(req, res) {
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  SquareOdbc
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-exports.odbcValidation = function(req, res) {
-  console.log(req.body);
-  SquareOdbc
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(square_odbcs) {
-      if (!square_odbcs) {
-        return res.sendStatus(404);
-      }
-      return res.send(square_odbcs);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single square_odbc
-exports.show = function(req, res) {
-  SquareOdbc
-    .findById(req.params.id)
-    .then(function(square_odbc) {
-      if (!square_odbc) {
-        return res.sendStatus(404);
-      }
-      return res.send(square_odbc);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new square_odbc in the DB.
-exports.create = function(req, res) {
-  SquareOdbc
-    .create(req.body)
-    .then(function(square_odbc) {
-      return res.status(201).send(square_odbc);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing square_odbc in the DB.
-exports.update = function(req, res) {
-  SquareOdbc
-    .findAll({
-      where: {
-        name: req.body.name,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function(square_odbcs) {
-      if (!square_odbcs) {
-        return res.sendStatus(404);
-      }
-      if (square_odbcs.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_ODBC'
-        })
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      SquareOdbc
-        .findById(req.params.id)
-        .then(function(square_odbc) {
-          if (!square_odbc) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(square_odbc, req.body);
-          updated.save()
-            .then(function() {
-              return res.status(200).send(square_odbc);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a square_odbc from the DB.
-exports.destroy = function(req, res) {
-  SquareOdbc
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(square_odbc) {
-      if (!square_odbc) {
-        return res.sendStatus(404);
-      }
-      square_odbc.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a square_project from the DB.
-exports.bulkDestroy = function(req, res) {
-  SquareOdbc
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/square_odbc/square_odbc.socket.js b/server/api/square_odbc/square_odbc.socket.js
index af0c04a..b88ccd1 100644
--- a/server/api/square_odbc/square_odbc.socket.js
+++ b/server/api/square_odbc/square_odbc.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var SquareOdbc = require('../../models').SquareOdbc;
-
-exports.register = function(socket) {
-  SquareOdbc.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  SquareOdbc.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('square_odbc:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('square_odbc:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/square_odbc/square_odbc.spec.js b/server/api/square_odbc/square_odbc.spec.js
index ce9350c..56cd55b 100644
--- a/server/api/square_odbc/square_odbc.spec.js
+++ b/server/api/square_odbc/square_odbc.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/square/odbc', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/square/odbc')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/square_project/index.js b/server/api/square_project/index.js
index e242768..5c39ce1 100644
--- a/server/api/square_project/index.js
+++ b/server/api/square_project/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./square_project.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id/download', controller.download);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.projectValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/square_project/square_project.controller.js b/server/api/square_project/square_project.controller.js
index 40dc276..ef4b86e 100644
--- a/server/api/square_project/square_project.controller.js
+++ b/server/api/square_project/square_project.controller.js
@@ -1,211 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var path = require('path');
-var config = require('../../config/environment');
-var util = require('util');
-
-var SquareProject = require('../../models').SquareProject;
-
-// Get list of square_projects
-exports.index = function(req, res) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  SquareProject
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-exports.projectValidation = function(req, res) {
-  console.log(req.body);
-  SquareProject
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(square_projects) {
-      if (!square_projects) {
-        return res.sendStatus(404);
-      }
-      return res.send(square_projects);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single square_project
-exports.show = function(req, res) {
-  SquareProject
-    .findById(req.params.id)
-    .then(function(square_project) {
-      if (!square_project) {
-        return res.sendStatus(404);
-      }
-      return res.send(square_project);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new square_project in the DB.
-exports.create = function(req, res) {
-  SquareProject
-    .create(req.body)
-    .then(function(square_project) {
-      return res.status(201).send(square_project);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing square_project in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  SquareProject
-    .findById(req.params.id)
-    .then(function(square_project) {
-      if (!square_project) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(square_project, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(square_project);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a square_project from the DB.
-exports.destroy = function(req, res) {
-  SquareProject
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(square_project) {
-      if (!square_project) {
-        return res.sendStatus(404);
-      }
-      square_project.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a square_project from the DB.
-exports.bulkDestroy = function(req, res) {
-  SquareProject
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.download = function(req, res, next) {
-  SquareProject
-    .findById(req.params.id)
-    .then(function(square_project) {
-      if (!square_project) {
-        return res.sendStatus(404);
-      }
-      console.log(req.query.filename);
-      res.set({
-        "Content-Disposition": "attachment; filename=\"" + req.query.filename +
-          ".xml\"",
-        "Content-Type": "txt/xml"
-      });
-      return res.send(square_project.preproduction);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/square_project/square_project.socket.js b/server/api/square_project/square_project.socket.js
index bc43e25..b1b0151 100644
--- a/server/api/square_project/square_project.socket.js
+++ b/server/api/square_project/square_project.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var SquareProject = require('../../models').SquareProject;
-
-exports.register = function(socket) {
-  SquareProject.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  SquareProject.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  SquareProject.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('square_project:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('square_project:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/square_project/square_project.spec.js b/server/api/square_project/square_project.spec.js
index 10a8297..93582d9 100644
--- a/server/api/square_project/square_project.spec.js
+++ b/server/api/square_project/square_project.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/square/projects', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/square/projects')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/sugarcrm_account/index.js b/server/api/sugarcrm_account/index.js
index e87249c..a37c5c8 100644
--- a/server/api/sugarcrm_account/index.js
+++ b/server/api/sugarcrm_account/index.js
@@ -1,21 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./sugarcrm_account.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount);
-router.get('/:id/fields', auth.isAuthenticated(), controller.getFields);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/validate/:field', auth.isAuthenticated(), controller.accountValidation);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/sugarcrm_account/index.spec.js b/server/api/sugarcrm_account/index.spec.js
index 758de1a..4713a81 100644
--- a/server/api/sugarcrm_account/index.spec.js
+++ b/server/api/sugarcrm_account/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var sugarcrmAccountCtrlStub = {
-  index: 'sugarcrmAccountCtrl.index',
-  show: 'sugarcrmAccountCtrl.show',
-  create: 'sugarcrmAccountCtrl.create',
-  update: 'sugarcrmAccountCtrl.update',
-  destroy: 'sugarcrmAccountCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var sugarcrmAccountIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './sugarcrm_account.controller': sugarcrmAccountCtrlStub
-});
-
-describe('SugarcrmAccount API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(sugarcrmAccountIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/sugarcrm/accounts', function() {
-
-    it('should route to sugarcrmAccount.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'sugarcrmAccountCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/sugarcrm/accounts/:id', function() {
-
-    it('should route to sugarcrmAccount.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'sugarcrmAccountCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/sugarcrm/accounts', function() {
-
-    it('should route to sugarcrmAccount.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'sugarcrmAccountCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/sugarcrm/accounts/:id', function() {
-
-    it('should route to sugarcrmAccount.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'sugarcrmAccountCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/sugarcrm/accounts/:id', function() {
-
-    it('should route to sugarcrmAccount.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'sugarcrmAccountCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/sugarcrm/accounts/:id', function() {
-
-    it('should route to sugarcrmAccount.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'sugarcrmAccountCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/sugarcrm_account/sugarcrm_account.controller.js b/server/api/sugarcrm_account/sugarcrm_account.controller.js
index cb7d78d..d8175ae 100644
--- a/server/api/sugarcrm_account/sugarcrm_account.controller.js
+++ b/server/api/sugarcrm_account/sugarcrm_account.controller.js
@@ -1,259 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/sugarcrm/accounts              ->  index
- * POST    /api/sugarcrm/accounts              ->  create
- * GET     /api/sugarcrm/accounts/:id          ->  show
- * PUT     /api/sugarcrm/accounts/:id          ->  update
- * DELETE  /api/sugarcrm/accounts/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-var util = require('util');
-
-var SugarcrmAccount = require('../../models').SugarcrmAccount;
-
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of SugarcrmAccounts
-exports.index = function(req, res) {
-  var attributes = ['description', 'name', 'username', 'remoteUri'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  SugarcrmAccount
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      return res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-}
-
-// Gets a single SugarcrmAccount from the DB
-exports.show = function(req, res) {
-  SugarcrmAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new SugarcrmAccount in the DB
-exports.create = function(req, res) {
-  SugarcrmAccount.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing SugarcrmAccount in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  SugarcrmAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a SugarcrmAccount from the DB
-exports.destroy = function(req, res) {
-  SugarcrmAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
-
-exports.checkAccount = function(req, res) {
-  SugarcrmAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(account) {
-      var sugar = require('node-sugarcrm-client');
-      sugar.init({
-        apiURL: stripTrailingSlash(account.remoteUri) + "/service/v4_1/rest.php",
-        login: account.username,
-        passwd: account.password
-      });
-      sugar.login(function(sessionId) {
-        if (!sessionId) {
-          return res.sendStatus(400);
-        }
-        return res.sendStatus(200);
-      });
-    })
-    .catch(handleError(res));
-}
-
-exports.bulkDestroy = function(req, res) {
-  SugarcrmAccount
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.accountValidation = function(req, res) {
-  var where = {};
-  where[req.params.field] = req.body.value;
-  SugarcrmAccount
-    .findAndCountAll({
-      where: where
-    })
-    .then(function(result) {
-      if (result.count) {
-        return res.status(200).send({
-          isValid: false,
-          value: req.body.value
-        });
-      }
-      return res.status(200).send({
-        isValid: true,
-        value: req.body.value
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.getFields = function(req, res) {
-  var sugar = require('node-sugarcrm-client');
-  SugarcrmAccount.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(account) {
-      sugar.init({
-        apiURL: stripTrailingSlash(account.remoteUri) + "/service/v4_1/rest.php",
-        login: account.username,
-        passwd: account.password
-      });
-      sugar.login(function(sessionId) {
-        if (!sessionId) {
-          return res.sendStatus(400);
-        }
-        var params = {
-          session: sessionId,
-          module_name: "Cases"
-        };
-        sugar.call("get_module_fields", params, function(result, err) {
-          if (err) {
-            return res.sendStatus(400);
-          }
-          return res.status(200).send(result.module_fields);
-        });
-      });
-    })
-    .catch(handleError(res));
-};
-
-function stripTrailingSlash(str) {
-  if (str.substr(-1) === '/') {
-    return str.substr(0, str.length - 1);
-  }
-  return str;
-}
\ No newline at end of file
diff --git a/server/api/sugarcrm_account/sugarcrm_account.socket.js b/server/api/sugarcrm_account/sugarcrm_account.socket.js
index 859bf6d..ba4ac57 100644
--- a/server/api/sugarcrm_account/sugarcrm_account.socket.js
+++ b/server/api/sugarcrm_account/sugarcrm_account.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var SugarcrmAccount = require('../../models').SugarcrmAccount;
-
-exports.register = function(socket) {
-  SugarcrmAccount.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  SugarcrmAccount.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('sugarcrm_account:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('sugarcrm_account:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/sugarcrm_configuration/index.js b/server/api/sugarcrm_configuration/index.js
index 90111bf..04e2705 100644
--- a/server/api/sugarcrm_configuration/index.js
+++ b/server/api/sugarcrm_configuration/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./sugarcrm_configuration.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/sugarcrm_configuration/index.spec.js b/server/api/sugarcrm_configuration/index.spec.js
index ba1b022..e4e163f 100644
--- a/server/api/sugarcrm_configuration/index.spec.js
+++ b/server/api/sugarcrm_configuration/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var sugarcrmConfigurationCtrlStub = {
-  index: 'sugarcrmConfigurationCtrl.index',
-  show: 'sugarcrmConfigurationCtrl.show',
-  create: 'sugarcrmConfigurationCtrl.create',
-  update: 'sugarcrmConfigurationCtrl.update',
-  destroy: 'sugarcrmConfigurationCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var sugarcrmConfigurationIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './sugarcrm_configuration.controller': sugarcrmConfigurationCtrlStub
-});
-
-describe('SugarcrmConfiguration API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(sugarcrmConfigurationIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/sugarcrm/configurations', function() {
-
-    it('should route to sugarcrmConfiguration.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'sugarcrmConfigurationCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/sugarcrm/configurations/:id', function() {
-
-    it('should route to sugarcrmConfiguration.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'sugarcrmConfigurationCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/sugarcrm/configurations', function() {
-
-    it('should route to sugarcrmConfiguration.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'sugarcrmConfigurationCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/sugarcrm/configurations/:id', function() {
-
-    it('should route to sugarcrmConfiguration.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'sugarcrmConfigurationCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/sugarcrm/configurations/:id', function() {
-
-    it('should route to sugarcrmConfiguration.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'sugarcrmConfigurationCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/sugarcrm/configurations/:id', function() {
-
-    it('should route to sugarcrmConfiguration.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'sugarcrmConfigurationCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/sugarcrm_configuration/sugarcrm_configuration.controller.js b/server/api/sugarcrm_configuration/sugarcrm_configuration.controller.js
index 5918283..2eb5fcf 100644
--- a/server/api/sugarcrm_configuration/sugarcrm_configuration.controller.js
+++ b/server/api/sugarcrm_configuration/sugarcrm_configuration.controller.js
@@ -1,145 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/sugarcrm/configurations              ->  index
- * POST    /api/sugarcrm/configurations              ->  create
- * GET     /api/sugarcrm/configurations/:id          ->  show
- * PUT     /api/sugarcrm/configurations/:id          ->  update
- * DELETE  /api/sugarcrm/configurations/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-
-var SugarcrmConfiguration = require('../../models').SugarcrmConfiguration;
-var SugarcrmField = require('../../models').SugarcrmField;
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) {
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of SugarcrmConfigurations
-exports.index = function(req, res) {
-  SugarcrmConfiguration.findAll({
-      where: req.query
-    })
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Gets a single SugarcrmConfiguration from the DB
-exports.show = function(req, res) {
-  SugarcrmConfiguration.find({
-      where: {
-        id: req.params.id
-      },
-      include: [{
-        model: SugarcrmField,
-        as: 'Subject'
-      }, {
-        model: SugarcrmField,
-        as: 'Description'
-      }, {
-        model: SugarcrmField,
-        as: 'Field'
-      }]
-    })
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new SugarcrmConfiguration in the DB
-exports.create = function(req, res) {
-  SugarcrmConfiguration.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing SugarcrmConfiguration in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  SugarcrmConfiguration.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a SugarcrmConfiguration from the DB
-exports.destroy = function(req, res) {
-  SugarcrmConfiguration.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
-
-exports.addConfigurationField = function(req, res, next) {
-  var sugarcrmConfiguration;
-  SugarcrmConfiguration
-    .findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(function(sugarcrm_configuration) {
-      sugarcrmConfiguration = sugarcrm_configuration;
-      return SugarcrmField.create(req.body)
-    })
-    .then(function(sugarcrmField) {
-      switch (req.params.type) {
-        case 'subject':
-          return [sugarcrmConfiguration.addSubject(sugarcrmField), sugarcrmField];
-        case 'description':
-          return [sugarcrmConfiguration.addDescription(sugarcrmField), sugarcrmField];
-        case 'field':
-          return [sugarcrmConfiguration.addField(sugarcrmField), sugarcrmField];
-      }
-    })
-    .spread(function(data, sugarcrmField) {
-      return res.status(201).json(sugarcrmField);
-    })
-    .catch(handleError(res));
-};
\ No newline at end of file
diff --git a/server/api/sugarcrm_configuration/sugarcrm_configuration.socket.js b/server/api/sugarcrm_configuration/sugarcrm_configuration.socket.js
index c4464da..9cb3d62 100644
--- a/server/api/sugarcrm_configuration/sugarcrm_configuration.socket.js
+++ b/server/api/sugarcrm_configuration/sugarcrm_configuration.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var SugarcrmConfiguration = require('../../models').SugarcrmConfiguration;
-
-exports.register = function(socket) {
-  SugarcrmConfiguration.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  SugarcrmConfiguration.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('sugarcrm_configuration:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('sugarcrm_configuration:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/sugarcrm_field/index.js b/server/api/sugarcrm_field/index.js
index edc0dc9..ba74cb2 100644
--- a/server/api/sugarcrm_field/index.js
+++ b/server/api/sugarcrm_field/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./sugarcrm_field.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/sugarcrm_field/index.spec.js b/server/api/sugarcrm_field/index.spec.js
index f8a20f7..04bdd3b 100644
--- a/server/api/sugarcrm_field/index.spec.js
+++ b/server/api/sugarcrm_field/index.spec.js
@@ -1,97 +1 @@
-'use strict';
-
-var proxyquire = require('proxyquire').noPreserveCache();
-
-var sugarcrmFieldCtrlStub = {
-  index: 'sugarcrmFieldCtrl.index',
-  show: 'sugarcrmFieldCtrl.show',
-  create: 'sugarcrmFieldCtrl.create',
-  update: 'sugarcrmFieldCtrl.update',
-  destroy: 'sugarcrmFieldCtrl.destroy'
-};
-
-var routerStub = {
-  get: sinon.spy(),
-  put: sinon.spy(),
-  patch: sinon.spy(),
-  post: sinon.spy(),
-  delete: sinon.spy()
-};
-
-// require the index with our stubbed out modules
-var sugarcrmFieldIndex = proxyquire('./index.js', {
-  'express': {
-    Router: function() {
-      return routerStub;
-    }
-  },
-  './sugarcrm_field.controller': sugarcrmFieldCtrlStub
-});
-
-describe('SugarcrmField API Router:', function() {
-
-  it('should return an express router instance', function() {
-    expect(sugarcrmFieldIndex).to.equal(routerStub);
-  });
-
-  describe('GET /api/sugarcrm/fields', function() {
-
-    it('should route to sugarcrmField.controller.index', function() {
-      expect(routerStub.get
-        .withArgs('/', 'sugarcrmFieldCtrl.index')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('GET /api/sugarcrm/fields/:id', function() {
-
-    it('should route to sugarcrmField.controller.show', function() {
-      expect(routerStub.get
-        .withArgs('/:id', 'sugarcrmFieldCtrl.show')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('POST /api/sugarcrm/fields', function() {
-
-    it('should route to sugarcrmField.controller.create', function() {
-      expect(routerStub.post
-        .withArgs('/', 'sugarcrmFieldCtrl.create')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PUT /api/sugarcrm/fields/:id', function() {
-
-    it('should route to sugarcrmField.controller.update', function() {
-      expect(routerStub.put
-        .withArgs('/:id', 'sugarcrmFieldCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('PATCH /api/sugarcrm/fields/:id', function() {
-
-    it('should route to sugarcrmField.controller.update', function() {
-      expect(routerStub.patch
-        .withArgs('/:id', 'sugarcrmFieldCtrl.update')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-  describe('DELETE /api/sugarcrm/fields/:id', function() {
-
-    it('should route to sugarcrmField.controller.destroy', function() {
-      expect(routerStub.delete
-        .withArgs('/:id', 'sugarcrmFieldCtrl.destroy')
-        ).to.have.been.calledOnce;
-    });
-
-  });
-
-});
\ No newline at end of file
diff --git a/server/api/sugarcrm_field/sugarcrm_field.controller.js b/server/api/sugarcrm_field/sugarcrm_field.controller.js
index eb6fe3d..54de92d 100644
--- a/server/api/sugarcrm_field/sugarcrm_field.controller.js
+++ b/server/api/sugarcrm_field/sugarcrm_field.controller.js
@@ -1,104 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /api/sugarcrm/fields              ->  index
- * POST    /api/sugarcrm/fields              ->  create
- * GET     /api/sugarcrm/fields/:id          ->  show
- * PUT     /api/sugarcrm/fields/:id          ->  update
- * DELETE  /api/sugarcrm/fields/:id          ->  destroy
- */
-
-'use strict';
-
-
-var _ = require('lodash');
-
-var SugarcrmField = require('../../models').SugarcrmField;
-
-
-function handleError(res, statusCode) {
-  statusCode = statusCode || 500;
-  return function(err) {
-    res.status(statusCode).send(err);
-  };
-}
-
-function responseWithResult(res, statusCode) {
-  statusCode = statusCode || 200;
-  return function(entity) {
-    if (entity) {
-      res.status(statusCode).json(entity);
-    }
-  };
-}
-
-function handleEntityNotFound(res) {
-  return function(entity) {
-    if (!entity) {
-      res.status(404).end();
-      return null;
-    }
-    return entity;
-  };
-}
-
-function saveUpdates(updates) {
-  return function(entity) {
-    return entity.updateAttributes(updates)
-      .then(function(updated) { 
-        return updated;
-      });
-  };
-}
-
-function removeEntity(res) {
-  return function(entity) {
-    if (entity) {
-      return entity.destroy()
-        .then(function() {
-          res.status(204).end();
-        });
-    }
-  };
-}
-
-// Gets a list of SugarcrmFields
-exports.index = function(req, res) {
-  SugarcrmField.findAll()
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Gets a single SugarcrmField from the DB
-exports.show = function(req, res) {
-  SugarcrmField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Creates a new SugarcrmField in the DB
-exports.create = function(req, res) {
-  SugarcrmField.create(req.body)
-    .then(responseWithResult(res, 201))
-    .catch(handleError(res));
-}
-
-// Updates an existing SugarcrmField in the DB
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  SugarcrmField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(saveUpdates(req.body))
-    .then(responseWithResult(res))
-    .catch(handleError(res));
-}
-
-// Deletes a SugarcrmField from the DB
-exports.destroy = function(req, res) {
-  SugarcrmField.findById(req.params.id)
-    .then(handleEntityNotFound(res))
-    .then(removeEntity(res))
-    .catch(handleError(res));
-}
\ No newline at end of file
diff --git a/server/api/sugarcrm_field/sugarcrm_field.socket.js b/server/api/sugarcrm_field/sugarcrm_field.socket.js
index bcc89cc..763e1e1 100644
--- a/server/api/sugarcrm_field/sugarcrm_field.socket.js
+++ b/server/api/sugarcrm_field/sugarcrm_field.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var SugarcrmField = require('../../models').SugarcrmField;
-
-exports.register = function(socket) {
-  SugarcrmField.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  SugarcrmField.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-};
-
-function onSave(socket, doc, cb) {
-  socket.emit('sugarcrm_field:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('sugarcrm_field:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/tag/index.js b/server/api/tag/index.js
index 10661b9..b8e8ffc 100644
--- a/server/api/tag/index.js
+++ b/server/api/tag/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./tag.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.tagValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/tag/tag.controller.js b/server/api/tag/tag.controller.js
index d7ba837..0248b44 100644
--- a/server/api/tag/tag.controller.js
+++ b/server/api/tag/tag.controller.js
@@ -1,210 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Tag = require('../../models').Tag;
-var util = require('util');
-
-// Get list of tags
-exports.index = function(req, res) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-  console.log(query);
-
-  Tag
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-exports.tagValidation = function(req, res) {
-  console.log(req.body);
-  Tag
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(tags) {
-      if (!tags) {
-        return res.sendStatus(404);
-      }
-      return res.send(tags);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single tag
-exports.show = function(req, res) {
-  Tag
-    .findById(req.params.id)
-    .then(function(tag) {
-      if (!tag) {
-        return res.sendStatus(404);
-      }
-      return res.send(tag);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new tag in the DB.
-exports.create = function(req, res) {
-  Tag
-    .create(req.body)
-    .then(function(tag) {
-      return res.status(201).send(tag);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing tag in the DB.
-exports.update = function(req, res) {
-  Tag
-    .findAll({
-      where: {
-        name: req.body.name,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function(tags) {
-      if (!tags) {
-        return res.sendStatus(404);
-      }
-      if (tags.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_TAG'
-        })
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      Tag
-        .find({
-          where: {
-            id: req.params.id
-          }
-        })
-        .then(function(tag) {
-          if (!tag) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(tag, req.body);
-          updated.save()
-            .then(function() {
-              return res.status(200).send(tag);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a tag from the DB.
-exports.destroy = function(req, res) {
-  Tag
-    .findById(req.params.id)
-    .then(function(tag) {
-      if (!tag) {
-        return res.sendStatus(404);
-      }
-      tag.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.bulkDestroy = function(req, res) {
-  Tag
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/tag/tag.socket.js b/server/api/tag/tag.socket.js
index 790b0a2..0d5ee51 100644
--- a/server/api/tag/tag.socket.js
+++ b/server/api/tag/tag.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Tag = require('../../models').Tag;
-
-exports.register = function(socket) {
-  Tag.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Tag.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('tag:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('tag:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/tag/tag.spec.js b/server/api/tag/tag.spec.js
index 794a03a..d65af4d 100644
--- a/server/api/tag/tag.spec.js
+++ b/server/api/tag/tag.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/tags', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/tags')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/team/index.js b/server/api/team/index.js
index 1bb002a..d7b968c 100644
--- a/server/api/team/index.js
+++ b/server/api/team/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./team.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/:id/agents', auth.isAuthenticated(), controller.addAgents);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.put('/:id/agents', auth.isAuthenticated(), controller.removeAgents);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/team/team.controller.js b/server/api/team/team.controller.js
index 7e39dde..51daa76 100644
--- a/server/api/team/team.controller.js
+++ b/server/api/team/team.controller.js
@@ -1,232 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var Team = require('../../models').Team;
-var User = require('../../models').User;
-
-// Get list of teams
-exports.index = function(req, res) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    include: [{
-      all: true
-    }],
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Team
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single team
-exports.show = function(req, res) {
-  Team
-    .find({
-      where: {
-        id: req.params.id
-      },
-      include: [User]
-    })
-    .then(function(team) {
-      if (!team) {
-        return res.sendStatus(404);
-      }
-      return res.send(team);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new team in the DB.
-exports.create = function(req, res) {
-  Team
-    .create(req.body)
-    .then(function(team) {
-      return res.status(201).send(team);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing team in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Team
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(team) {
-      if (!team) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(team, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(team);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a team from the DB.
-exports.destroy = function(req, res) {
-  Team
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(team) {
-      if (!team) {
-        return res.sendStatus(404);
-      }
-      team.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function(req, res) {
-  Team
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing user_has_mail_queue in the DB.
-exports.addAgents = function(req, res, next) {
-  Team
-    .findById(req.params.id)
-    .then(function(team) {
-      if (team) {
-        // QUEUE FOUND
-        // ADD AGENTS
-        team
-          .addUsers(req.body.agents)
-          .then(function() {
-            return res.sendStatus(200);
-          })
-          .catch(function(err) {
-            return next(err);
-          });
-      } else {
-        return next(new Error('no mail queue found'));
-      }
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-exports.removeAgents = function(req, res, next) {
-  Team
-    .findById(req.params.id)
-    .then(function(team) {
-      if (team) {
-        // QUEUE FOUND
-        // REMOVE AGENTS
-        team
-          .removeUsers(req.body.agents)
-          .then(function() {
-            return res.sendStatus(200);
-          })
-          .catch(function(err) {
-            return next(err);
-          });
-      } else {
-        return next(new Error('no mail queue found'));
-      }
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/team/team.socket.js b/server/api/team/team.socket.js
index 3f89dc2..3f66f00 100644
--- a/server/api/team/team.socket.js
+++ b/server/api/team/team.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var team = require('../../models').Team;
-
-exports.register = function(socket) {
-  team.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  team.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  team.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('team:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('team:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/team/team.spec.js b/server/api/team/team.spec.js
index b76928a..816b6c7 100644
--- a/server/api/team/team.spec.js
+++ b/server/api/team/team.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/teams', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/teams')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/thing/index.js b/server/api/thing/index.js
index 845c9f0..f55aaa2 100644
--- a/server/api/thing/index.js
+++ b/server/api/thing/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./thing.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/thing/thing.controller.js b/server/api/thing/thing.controller.js
index 7d4d710..a00d1cb 100644
--- a/server/api/thing/thing.controller.js
+++ b/server/api/thing/thing.controller.js
@@ -1,98 +1 @@
-/**
- * Using Rails-like standard naming convention for endpoints.
- * GET     /things              ->  index
- * POST    /things              ->  create
- * GET     /things/:id          ->  show
- * PUT     /things/:id          ->  update
- * DELETE  /things/:id          ->  destroy
- */
-
-'use strict';
-
-var _ = require('lodash');
-var Thing = require('../../models').Thing;
-
-// Get list of things
-exports.index = function(req, res, next) {
-  Thing
-    .findAll()
-    .then(function(things) {
-      return res.status(200).send(things);
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Get a single thing
-exports.show = function(req, res, next) {
-  Thing
-    .findById(req.params.id)
-    .then(function(thing) {
-      if (!thing) {
-        return res.sendStatus(404);
-      }
-      return res.send(thing);
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Creates a new thing in the DB.
-exports.create = function(req, res, next) {
-  Thing
-    .create(req.body)
-    .then(function(thing) {
-      return res.status(201).send(thing);
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Updates an existing thing in the DB.
-exports.update = function(req, res, next) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Thing
-    .findById(req.params.id)
-    .then(function(thing) {
-      if (!thing) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(thing, req.body);
-      updated.save()
-      .then(function() {
-        return res.status(200).send(thing);
-      })
-      .catch(function(err) {
-        return next(err);
-      });
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Deletes a thing from the DB.
-exports.destroy = function(req, res, next) {
-  Thing
-    .findById(req.params.id)
-    .then(function(thing) {
-      if (!thing) {
-        return res.sendStatus(404);
-      }
-      thing.destroy()
-      .then(function() {
-        return res.sendStatus(204);
-      })
-      .catch(function(err) {
-        return next(err);
-      });
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
\ No newline at end of file
diff --git a/server/api/thing/thing.socket.js b/server/api/thing/thing.socket.js
index 55b9c5a..64fb289 100644
--- a/server/api/thing/thing.socket.js
+++ b/server/api/thing/thing.socket.js
@@ -1,27 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-//var thing = require('./thing.model');
-var thing = require('../../models').Thing;
-
-exports.register = function (socket) {
-
-  thing.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-
-  thing.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('thing:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('thing:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/thing/thing.spec.js b/server/api/thing/thing.spec.js
index 17c8c6c..c9a6a6d 100644
--- a/server/api/thing/thing.spec.js
+++ b/server/api/thing/thing.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/things', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/things')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/trigger/index.js b/server/api/trigger/index.js
index e2c0971..9f86ea0 100644
--- a/server/api/trigger/index.js
+++ b/server/api/trigger/index.js
@@ -1,17 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./trigger.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/trigger/trigger.controller.js b/server/api/trigger/trigger.controller.js
index 87dccb3..f1c89e5 100644
--- a/server/api/trigger/trigger.controller.js
+++ b/server/api/trigger/trigger.controller.js
@@ -1,168 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var Trigger = require('../../models').Trigger;
-
-// Get list of agents
-exports.index = function(req, res, next) {
-
-  var attributes = ['fullname', 'name', 'email'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Trigger
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single Trigger
-exports.show = function(req, res) {
-  Trigger
-    .findById(req.params.id)
-    .then(function(Trigger) {
-      if (!Trigger) {
-        return res.sendStatus(404);
-      }
-      return res.send(Trigger);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new Trigger in the DB.
-exports.create = function(req, res) {
-  Trigger
-    .create(req.body)
-    .then(function() {
-      return res.sendStatus(201);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing Trigger in the DB.
-exports.update = function(req, res, next) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Trigger
-    .findById(req.params.id)
-    .then(function(Trigger) {
-      if (!Trigger) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(Trigger, req.body);
-      updated
-        .save()
-        .then(function() {
-          return res.status(200).send(Trigger);
-        })
-        .catch(function(err) {
-          // return handleError(res, err);
-          return next(err);
-
-        });
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Deletes a Trigger from the DB.
-exports.destroy = function(req, res) {
-  Trigger
-    .findById(req.params.id)
-    .then(function(Trigger) {
-      if (!Trigger) {
-        return res.sendStatus(404);
-      }
-      Trigger.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.bulkDestroy = function(req, res) {
-  Trigger
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/trigger/trigger.socket.js b/server/api/trigger/trigger.socket.js
index 7fe5fa2..89134b0 100644
--- a/server/api/trigger/trigger.socket.js
+++ b/server/api/trigger/trigger.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Trigger = require('../../models').Trigger;
-
-exports.register = function(socket) {
-  Trigger.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Trigger.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('trigger:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('trigger:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/trigger/trigger.spec.js b/server/api/trigger/trigger.spec.js
index c88586d..addb881 100644
--- a/server/api/trigger/trigger.spec.js
+++ b/server/api/trigger/trigger.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/triggers', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/triggers')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/trunk/index.js b/server/api/trunk/index.js
index ea72fdd..4ae6e85 100644
--- a/server/api/trunk/index.js
+++ b/server/api/trunk/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./trunk.controller');
-var config = require('../../config/environment');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.trunkValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/trunk/trunk.ami.js b/server/api/trunk/trunk.ami.js
index 32b4a66..a64df42 100644
--- a/server/api/trunk/trunk.ami.js
+++ b/server/api/trunk/trunk.ami.js
@@ -1,90 +1 @@
-'use strict';
-
-var fs = require('fs');
-var util = require('util');
-var path = require('path');
-var config = require('../../config/environment');
-var Trunk = require('../../models').Trunk;
-var VoiceExtension = require('../../models').VoiceExtension;
-var _ = require('lodash');
-
-exports.register = function(ami) {
-  Trunk.afterCreate(function(doc) {
-    console.log('create trunk hook');
-    trunksRewrite(doc, ami, false);
-  })
-  Trunk.afterUpdate(function(doc) {
-    console.log('update trunk hook');
-    trunksRewrite(doc, ami, false);
-  })
-  Trunk.afterDelete(function(doc) {
-    console.log('delete trunk hook');
-    trunksRewrite(doc, ami, true);
-  })
-}
-
-function trunksRewrite(doc, ami, deleteTrunk) {
-  var trunksFile = '';
-  if (!deleteTrunk) {
-    var newTrunk = _.clone(doc.dataValues);
-    delete newTrunk.id;
-    delete newTrunk.createdAt;
-    delete newTrunk.updatedAt;
-    trunksFile += util.format('[%s]\n', newTrunk.name);
-    if (newTrunk.otherFields) {
-      trunksFile += util.format('%s\n', newTrunk.otherFields);
-      delete newTrunk.otherFields;
-    }
-    for (var key in newTrunk) {
-      if (newTrunk[key]) {
-        trunksFile += util.format('%s=%s\n', key, newTrunk[key]);
-      }
-    }
-  }
-  Trunk
-    .findAll({
-      where: {
-        id: {
-          $ne: doc.id
-        }
-      }
-    })
-    .then(function(trunks) {
-      var oldTrunks = _.pluck(trunks, 'dataValues');
-      oldTrunks.forEach(function(element) {
-        delete element.id;
-        delete element.createdAt;
-        delete element.updatedAt;
-        trunksFile += util.format('[%s]\n', element.name);
-        if (element.otherFields) {
-          trunksFile += util.format('%s\n', element.otherFields);
-          delete element.otherFields;
-        }
-        for (var key in element) {
-          if (element[key]) {
-            trunksFile += util.format('%s=%s\n', key, element[key]);
-          }
-        }
-      });
-      fs.writeFile(path.join(config.root, 'server/files/asterisk/sip_xcally_trunks.conf'), trunksFile, {
-        flags: 'w',
-        mode: parseInt('0777', 8)
-      }, function(err) {
-        if (err) throw err;
-        console.log("Trunks file saved!");
-        ami.action({
-          Action: 'Reload',
-          Module: 'chan_sip'
-        }, function(err, res) {
-          if (err) {
-            console.error(err);
-          } else {
-            console.log(res);
-          }
-        });
-      });
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
\ No newline at end of file
diff --git a/server/api/trunk/trunk.controller.js b/server/api/trunk/trunk.controller.js
index 2ccdd9a..a5835a7 100644
--- a/server/api/trunk/trunk.controller.js
+++ b/server/api/trunk/trunk.controller.js
@@ -1,298 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Trunk = require('../../models').Trunk;
-var VoiceExtension = require('../../models').VoiceExtension;
-var sequelize = require('../../models').sequelize;
-var util = require('util');
-
-// Get list of trunks
-exports.index = function(req, res, next) {
-
-  var attributes = ['name', 'host', 'context', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      case 'role':
-        query.where.role = {
-          $or: value.split(/[\s,]+/)
-        };
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Trunk
-    .findAndCountAll(query)
-    .then(function(result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-// Get a single trunk
-exports.show = function(req, res) {
-  Trunk
-    .findById(req.params.id)
-    .then(function(trunk) {
-      if (!trunk) {
-        return res.sendStatus(404);
-      }
-      return res.send(trunk);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Validate the existence of a trunk
-exports.trunkValidation = function(req, res) {
-  console.log(req.body);
-  Trunk
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(trunks) {
-      if (!trunks) {
-        return res.sendStatus(404);
-      }
-      return res.send(trunks);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new trunk in the DB.
-exports.create = function(req, res) {
-  Trunk
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(existingTrunks) {
-      console.log(existingTrunks);
-      console.log('Finding app row.....');
-      if (!existingTrunks) {
-        return res.sendStatus(404);
-      }
-      if (existingTrunks.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_TRUNK'
-        });
-      }
-      Trunk
-        .create(req.body)
-        .then(function(trunk) {
-          return res.status(201).send(trunk);
-        })
-        .catch(function(err) {
-          console.log('trunks create', err);
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      console.log('trunks findall', err);
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing trunk in the DB.
-exports.update = function(req, res, next) {
-  Trunk
-    .findAll({
-      where: {
-        name: req.body.name,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function(existingTrunks) {
-      console.log(existingTrunks);
-      console.log('Finding app row.....');
-      if (!existingTrunks) {
-        return res.sendStatus(404);
-      }
-      if (existingTrunks.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_TRUNK'
-        });
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      Trunk
-        .findById(req.params.id)
-        .then(function(trunk) {
-          if (!trunk) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(trunk, req.body);
-          return sequelize.transaction(function(t) {
-              return updated.save({
-                  transaction: t
-                })
-                .then(function(trunk) {
-                  return VoiceExtension
-                    .update({
-                      trunk: trunk.name,
-                      cutdigits: sequelize.literal('cutdigits')
-                    }, {
-                      where: {
-                        TrunkId: trunk.id
-                      }
-                    }, {
-                      transaction: t
-                    })
-                    .then(function() {
-                      return res.status(200).send(trunk);
-                    })
-                })
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return next(err);
-        });
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Deletes a trunk from the DB.
-exports.destroy = function(req, res) {
-  Trunk
-    .findById(req.params.id)
-    .then(function(trunk) {
-      if (!trunk) {
-        return res.sendStatus(404);
-      }
-      trunk.getVoiceExtensions({
-          where: {
-            isApp: true
-          }
-        })
-        .then(function(outbound_dials) {
-          console.log(outbound_dials.length);
-          if (outbound_dials.length > 0) {
-            return res.status(500).send({
-              message: 'MESSAGE_TRUNK_OUTBOUND_ASSOCIATED'
-            });
-          }
-          trunk.destroy()
-            .then(function() {
-              return res.sendStatus(204);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes multiple trunk from the DB.
-exports.bulkDestroy = function(req, res) {
-  var associatedTrunks = false;
-  Trunk
-    .findAll({
-      where: {
-        id: req.query.id
-      },
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(trunks) {
-      if (!trunks) {
-        return res.sendStatus(404);
-      }
-      trunks.forEach(function(element) {
-        if (element.VoiceExtensions.length > 0) {
-          associatedTrunks = true;
-        }
-      });
-      if (associatedTrunks) {
-        return res.status(500).send({
-          message: 'MESSAGE_TRUNK_OUTBOUND_ASSOCIATED'
-        });
-      }
-      Trunk
-        .destroy({
-          where: {
-            id: req.query.id
-          },
-          individualHooks: true
-        })
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/trunk/trunk.socket.js b/server/api/trunk/trunk.socket.js
index d4f7e36..608bf0f 100644
--- a/server/api/trunk/trunk.socket.js
+++ b/server/api/trunk/trunk.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Trunk = require('../../models').User;
-
-exports.register = function(socket) {
-  Trunk.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Trunk.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('trunk:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('trunk:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/trunk/trunk.spec.js b/server/api/trunk/trunk.spec.js
index 48ad76c..89570d6 100644
--- a/server/api/trunk/trunk.spec.js
+++ b/server/api/trunk/trunk.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/trunks', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/trunks')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/update/index.js b/server/api/update/index.js
index d57b32c..80a4216 100644
--- a/server/api/update/index.js
+++ b/server/api/update/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./update.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), auth.hasRole('admin'), controller.index);
-router.get('/pull', auth.isAuthenticated(), auth.hasRole('admin'), controller.pull);
-// router.get('/checkout/:hash', controller.checkout);
-// router.get('/:id', controller.show);
-// router.post('/', controller.create);
-// router.put('/:id', controller.update);
-// router.patch('/:id', controller.update);
-// router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/update/update.controller.js b/server/api/update/update.controller.js
index 6637294..4fc9449 100644
--- a/server/api/update/update.controller.js
+++ b/server/api/update/update.controller.js
@@ -1,127 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var path = require("path");
-var config = require('../../config/environment');
-
-var Git = require('simple-git')(path.join(config.root));
-
-var Update = require('../../models').Update;
-
-// Get list of updates
-exports.index = function(req, res) {
-  Git
-    .log(function(err, logs) {
-      if (err) {
-        return handleError(res, err);
-      }
-
-      var versions = [];
-      logs.all.forEach(function(log) {
-        log.version = log.message.split('|')[1] || 'unknown';
-        log.message = log.message.split('|')[0];
-        versions.push(log);
-      });
-      //logs.all = _.take(logs.all, 10);
-      console.log("Latest available tag: %s", logs.latest);
-      return res.status(200).send(versions);
-    });
-};
-
-// Get a single update
-exports.show = function(req, res) {
-
-};
-
-// Get a single update
-exports.pull = function(req, res) {
-  Git
-    .pull(function(err, update) {
-      if (err) {
-        return handleError(res, err);
-      }
-      return res.status(201).send(update);
-    });
-};
-
-// Get a single update
-exports.checkout = function(req, res) {
-  console.log('req.params.hash', req.params.hash);
-  Git
-    .checkout(req.params.hash, function(err, update) {
-      if (err) {
-        return handleError(res, err);
-      }
-      return res.status(201).send(update);
-    });
-};
-
-// Creates a new update in the DB.
-exports.create = function(req, res) {
-  Update
-    .create(req.body)
-    .then(function(update) {
-      return res.status(201).send(update);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing update in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Update
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(update) {
-      if (!update) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(update, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(update);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a update from the DB.
-exports.destroy = function(req, res) {
-  Update
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(update) {
-      if (!update) {
-        return res.sendStatus(404);
-      }
-      update.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/update/update.js b/server/api/update/update.js
index 6333030..b9cca71 100644
--- a/server/api/update/update.js
+++ b/server/api/update/update.js
@@ -1,11 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Update = sequelize.define('Update', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING
-  });
-
-  return Update;
-};
+var _0x97f1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x55\x70\x64\x61\x74\x65","\x53\x54\x52\x49\x4E\x47","\x64\x65\x66\x69\x6E\x65"];_0x97f1[0];module[_0x97f1[1]]=function(_0xf2b5x1,_0xf2b5x2){var _0xf2b5x3=_0xf2b5x1[_0x97f1[4]](_0x97f1[2],{name:_0xf2b5x2[_0x97f1[3]],description:_0xf2b5x2[_0x97f1[3]]});return _0xf2b5x3;};
\ No newline at end of file
diff --git a/server/api/update/update.socket.js b/server/api/update/update.socket.js
index 149d026..7d16934 100644
--- a/server/api/update/update.socket.js
+++ b/server/api/update/update.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Update = require('../../models').Update;
-
-exports.register = function(socket) {
-  Update.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  Update.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('update:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('update:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/update/update.spec.js b/server/api/update/update.spec.js
index 21276e3..4402c79 100644
--- a/server/api/update/update.spec.js
+++ b/server/api/update/update.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/updates', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/updates')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/upload/index.js b/server/api/upload/index.js
index 3b2eded..528965f 100644
--- a/server/api/upload/index.js
+++ b/server/api/upload/index.js
@@ -1,17 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./upload.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.download);
-router.get('/stream/:id', auth.isAuthenticated(), controller.stream);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/upload/upload.controller.js b/server/api/upload/upload.controller.js
index 710b3a0..94f4268 100644
--- a/server/api/upload/upload.controller.js
+++ b/server/api/upload/upload.controller.js
@@ -1,269 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Upload = require('../../models').Upload;
-var uploadFile = require('upload-file');
-var sr = require('simple-random');
-var sox = require('sox');
-var path = require('path');
-var config = require('../../config/environment');
-var fs = require('fs');
-var sequelize = require('../../models').sequelize;
-var base64 = require('file-base64');
-
-// Get list of uploads
-exports.index = function(req, res) {
-  Upload
-    .findAll()
-    .then(function(uploads) {
-      return res.status(200).send(uploads);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single upload
-exports.show = function(req, res) {
-  Upload
-    .findById(req.params.id)
-    .then(function(upload) {
-      if (!upload) {
-        return res.sendStatus(404);
-      }
-      return res.send(upload);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new upload in the DB.
-exports.create = function(req, res) {
-  var upload = new uploadFile({
-    dest: path.join(config.root, 'server/files/sounds/original'),
-    maxFileSize: 15 * 1000000,
-    maxNumberOfFiles: 10,
-    minNumberOfFiles: 0,
-    acceptFileTypes: /(\.|\/)(wav|mp3|gsm|ogg)$/i,
-    rename: function(name, file) {
-      return sr() + path.extname(file.filename);
-    },
-    messages: {
-      maxNumberOfFiles: "Max number of files upload exceeded",
-      acceptFileTypes: "Only wav,mp3,gsm, and ogg format accepted",
-      maxFileSize: "The maximum file size is 15 Mb",
-      invalidRequest: "Invalid request"
-    }
-  });
-
-  upload.on('end', function(fields, files) {
-    var job_details = {};
-    job_details.description = "";
-    job_details.name = job_details.display_name = path.basename(files.file.path, path.extname(files.file.filename));
-    job_details.save_name = path.basename(files.file.filename, path.extname(files.file.filename));
-    job_details.original_path = path.join(config.root, 'server/files/sounds/original');
-    job_details.converted_path = path.join(config.root, 'server/files/sounds/converted');
-
-    if (!files.file.filename) {
-      return res.status(500).send(upload);
-    }
-
-    var filepath = path.join(job_details.original_path, job_details.save_name + path.extname(files.file.filename));
-    var destination = path.join(job_details.converted_path, job_details.save_name + '.wav');
-    //
-
-    fs.chmodSync(filepath, parseInt('0777', 8));
-    sox.identify(filepath, function(err, result) {
-      console.log('************** Result: ', result);
-    });
-
-    var job = sox.transcode(filepath, destination, {
-      sampleRate: 8000,
-      format: 'wav',
-      channelCount: 1,
-      bitRate: 192 * 1024,
-      compressionQuality: 5,
-    });
-
-
-
-    job.on('error', function(err) {
-      console.error('********** Conversion Error: ', err);
-      fs.unlink(filepath, function(err) {
-        if (err)
-          return handleError(res, err);
-      });
-      return handleError(res, err);
-    });
-
-    job.on('progress', function(amountDone, amountTotal) {
-      // console.log("*********** Progress", amountDone, amountTotal);
-    });
-
-    job.on('src', function(info) {
-      // console.log('********** src: ', info);
-      /* info looks like:
-      {
-        format: 'wav',
-        duration: 1.5,
-        sampleCount: 66150,
-        channelCount: 1,
-        bitRate: 722944,
-        sampleRate: 44100,
-      }
-      */
-      job_details.original_format = info.format;
-      job_details.original_duration = info.duration * 1000;
-      job_details.original_sampleCount = info.sampleCount;
-      job_details.original_channelCount = info.channelCount;
-      job_details.original_bitRate = info.bitRate;
-      job_details.original_sampleRate = info.sampleRate;
-    });
-
-    job.on('dest', function(info) {
-      // console.log('********** dest: ', info);
-      /* info looks like:
-      {
-        sampleRate: 44100,
-        format: 'mp3',
-        channelCount: 2,
-        sampleCount: 67958,
-        duration: 1.540998,
-        bitRate: 196608,
-      }
-      */
-      job_details.converted_format = info.format;
-      job_details.converted_duration = info.duration * 1000;
-      job_details.converted_sampleCount = info.sampleCount;
-      job_details.converted_channelCount = info.channelCount;
-      job_details.converted_bitRate = info.bitRate;
-      job_details.converted_sampleRate = info.sampleRate;
-    });
-
-    job.on('end', function() {
-      console.log("Conversion completed");
-      fs.chmodSync(destination, parseInt('0777', 8));
-      Upload
-        .create(job_details)
-        .then(function(upload) {
-          return res.status(201).send(upload);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    });
-
-    job.start();
-
-  });
-
-  upload.on('error', function(err) {
-    console.log('********** Upload error :', err)
-    return handleError(res, err);
-  });
-
-  upload.parse(req);
-};
-
-// Updates an existing upload in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Upload
-    .findById(req.params.id)
-    .then(function(upload) {
-      if (!upload) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(upload, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(upload);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a upload from the DB.
-exports.destroy = function(req, res) {
-  Upload
-    .findById(req.params.id)
-    .then(function(upload) {
-      if (!upload) {
-        return res.status(404).send(upload);
-      }
-      var original_filepath = path.join(upload.original_path, upload.save_name + '.' + upload.original_format);
-      var converted_filepath = path.join(upload.converted_path, upload.save_name + '.' + upload.converted_format);
-      return sequelize.transaction(function(t) {
-          return upload.destroy({
-              transaction: t
-            })
-            .then(function() {
-              fs.unlink(original_filepath, function(err) {
-                if (err)
-                  return handleError(res, err);
-              });
-              fs.unlink(converted_filepath, function(err) {
-                if (err)
-                  return handleError(res, err);
-              });
-              return res.status(200).send(upload);
-            })
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-//Download an uploaded file
-exports.download = function(req, res) {
-  Upload
-    .findById(req.params.id)
-    .then(function(upload) {
-      if (!upload) {
-        return res.status(404).send(upload);
-      }
-      var original_filepath = path.join(upload.original_path, upload.save_name + '.' + upload.original_format);
-      res.status(200).download(original_filepath, upload.display_name + '.' + upload.original_format, function(err) {
-        if (err) {
-          return handleError(res, err);
-        } else {
-          console.log("Sent file under :", original_filepath);
-        }
-      });
-    })
-};
-
-//Stream an uploaded file
-exports.stream = function(req, res) {
-  Upload
-    .findById(req.params.id)
-    .then(function(upload) {
-      if (!upload) {
-        return res.status(404).send(upload);
-      }
-      var original_filepath = path.join(upload.converted_path, upload.save_name + '.' + upload.original_format);
-      base64.encode(original_filepath, function(err, base64String) {
-        if (err) {
-          console.log(err);
-          return handleError(res, err);
-        } else {
-          return res.status(200).send(base64String);
-        }
-      });
-    })
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/upload/upload.socket.js b/server/api/upload/upload.socket.js
index 938d94b..c59872c 100644
--- a/server/api/upload/upload.socket.js
+++ b/server/api/upload/upload.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var upload = require('../../models').Upload;
-
-exports.register = function(socket) {
-  upload.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  upload.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('upload:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('upload:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/upload/upload.spec.js b/server/api/upload/upload.spec.js
index bde9f38..e426559 100644
--- a/server/api/upload/upload.spec.js
+++ b/server/api/upload/upload.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/uploads', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/uploads')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user/index.js b/server/api/user/index.js
index ba13b49..f981b0e 100644
--- a/server/api/user/index.js
+++ b/server/api/user/index.js
@@ -1,25 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./user.controller');
-var config = require('../../config/environment');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/me', auth.isAuthenticated(), controller.me);
-router.get('/all', auth.isAuthenticated(), controller.getUsers);
-router.get('/avatar/:filename', controller.getAvatar);
-router.get('/:id/avatar', controller.getAvatarById);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/validate/:field', auth.isAuthenticated(), controller.userValidation);
-router.put('/password', auth.isAuthenticated(), controller.changePassword);
-router.put('/password/:id/reset', auth.isAuthenticated(), auth.hasRole('admin'), controller.resetPassword);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/:id/avatar', auth.isAuthenticated(), controller.changeAvatar);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/user/user.ami.js b/server/api/user/user.ami.js
index d26deb4..a805161 100644
--- a/server/api/user/user.ami.js
+++ b/server/api/user/user.ami.js
@@ -1,75 +1 @@
-'use strict';
-
-var fs = require('fs');
-var util = require('util');
-var path = require('path');
-var config = require('../../config/environment');
-var User = require('../../models').User;
-var VoiceExtension = require('../../models').VoiceExtension;
-
-exports.register = function (ami) {
-  User.afterCreate(function (doc) {
-    createCallerID(doc);
-    createExtension(doc);
-  })
-  User.afterUpdate(function (doc) {
-    updateExtension(doc);
-    createCallerID(doc);
-  })
-}
-
-
-function createCallerID(doc) {
-  if (doc.name && doc.internal) {
-    doc.callerid = util.format('"%s" <%s>', doc.name, doc.internal);
-    doc.save();
-  }
-
-  return;
-}
-
-function updateExtension(doc) {
-  if (doc.changed('name')) {
-    doc
-      .getUserExtensions()
-      .then(function (userExtensions) {
-        userExtensions.forEach(function (elem) {
-          elem.exten = (elem.exten === doc._previousDataValues.internal) ? doc.internal : doc.name;
-          elem.appdata = 'SIP/' + doc.name;
-          elem.save();
-        })
-      })
-      .catch(function (err) {
-        console.log(err);
-      });
-  }
-}
-
-
-function createExtension(doc) {
-  if (doc.internal) {
-    var userDials = [{
-      context: 'from-sip',
-      exten: doc.internal,
-      priority: 1,
-      app: 'Dial',
-      appdata: 'SIP/' + doc.name,
-      UserId: doc.id,
-      type: 'internal'
-    }, {
-      context: 'from-sip',
-      exten: doc.name,
-      priority: 1,
-      app: 'Dial',
-      appdata: 'SIP/' + doc.name,
-      UserId: doc.id,
-      type: 'internal'
-    }];
-
-    return VoiceExtension
-      .bulkCreate(userDials)
-      .catch(function (err) {
-        console.log(err);
-      });
-  }
-}
\ No newline at end of file
diff --git a/server/api/user/user.controller.js b/server/api/user/user.controller.js
index 3e2e864..63c4d23 100644
--- a/server/api/user/user.controller.js
+++ b/server/api/user/user.controller.js
@@ -1,447 +1 @@
-'use strict';
-
-var User = require('../../models').User;
-var Module = require('../../models').Module;
-var config = require('../../config/environment');
-
-var passport = require('passport');
-var moment = require('moment');
-var jwt = require('jsonwebtoken');
-var uploadFile = require('upload-file');
-var path = require('path');
-var fs = require('fs');
-var _ = require('lodash');
-var util = require('util');
-var sr = require('simple-random');
-
-/**
- * Get list of admin/user
- */
-exports.index = function(req, res, next) {
-
-  var attributes = ['fullname', 'name', 'email', 'role'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {
-      role: ['admin', 'user']
-    },
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  User
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      return res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-
-};
-
-/**
- * Get list of admin/user/agent
- */
-exports.getUsers = function(req, res, next) {
-  User
-    .findAll({
-      where: {
-        role: {
-          $in: ['admin', 'user', 'agent']
-        }
-      }
-    })
-    .then(function(users) {
-      return res.status(200).send(users);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-/**
- * Creates a new user
- */
-exports.create = function(req, res, next) {
-
-  var body = req.body;
-  _(body).keys().sort().each(function(key) {
-    var value = body[key];
-  });
-
-  var newUser = User.build(req.body);
-  newUser.provider = 'local';
-  newUser
-    .save()
-    .then(function(user) {
-      var token = jwt.sign({
-        id: user.id
-      }, config.session.secret, {
-        expiresIn: "5h"
-      });
-      return res.status(201).send({
-        token: token
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-/**
- * Get a single user
- */
-exports.show = function(req, res, next) {
-
-  User
-    .findById(req.params.id)
-    .then(function(user) {
-      if (user) {
-        return res.status(200).send(user);
-      } else {
-        return res.sendStatus(404);
-      }
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-/**
- * Deletes a user
- */
-exports.destroy = function(req, res, next) {
-  var userId = req.params.id;
-  // console.log(req.params);
-  // console.log(req.body);
-
-  User
-    .findById(userId)
-    .then(function(user) {
-      if (user) {
-        user
-          .destroy()
-          .then(function(user) {
-            console.log(user);
-            return res.status(200).send(user);
-          })
-          .catch(function(err) {
-            return handleError(res, err);
-          });
-      } else {
-        return res.sendStatus(404);
-      }
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-/**
- * Change a user password
- */
-exports.changePassword = function(req, res, next) {
-  var userId = req.user.id;
-  var oldPass = String(req.body.oldPassword);
-  var newPass = String(req.body.newPassword);
-  User
-    .findById(userId)
-    .then(function(user) {
-      if (user.authenticate(oldPass)) {
-        user.password = newPass;
-        user.save()
-          .then(function() {
-            return res.status(200).send(user);
-          })
-          .catch(function(err) {
-            return handleError(res, err);
-          });
-      } else {
-        return res.sendStatus(403);
-      }
-    });
-};
-
-/**
- * Change a user password by admin
- */
-exports.resetPassword = function(req, res, next) {
-  var newPass = String(req.body.newPassword);
-  User
-    .findById(req.params.id)
-    .then(function(user) {
-      user.password = newPass;
-      user.save()
-        .then(function() {
-          return res.status(200).send(user);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    });
-};
-
-/**
- * Change the avatar of the user
- */
-exports.changeAvatar = function(req, res, next) {
-
-  var upload = new uploadFile({
-    dest: path.join(config.root, 'server', 'files', 'images'),
-    maxNumberOfFiles: 1,
-    minNumberOfFiles: 0,
-    acceptFileTypes: /(\.|\/)(jpeg|png)$/i,
-    rename: function(name, file) {
-      return sr() + path.extname(file.filename);
-      // return 'avatar' + req.params.id + path.extname(file.filename);
-    },
-    messages: {
-      maxNumberOfFiles: "Max number of files upload exceeded",
-      acceptFileTypes: "Only jpeg and png format accepted",
-      // maxFileSize: "The maximum file size is 5 Mb",
-      invalidRequest: "Invalid request"
-    }
-  });
-
-  upload.on('end', function(fields, files) {
-    if (!files.file.filename) {
-      return res.status(500).send(upload);
-    } else {
-      User
-        .findById(req.params.id)
-        .then(function(user) {
-          if (user) {
-            user.updateAttributes({
-                userpic: files.file.filename
-              })
-              .then(function() {
-                return res.status(200).send(user);
-              })
-              .catch(function(err) {
-                return handleError(res, err);
-              });
-          } else {
-            return res.sendStatus(404);
-          }
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    }
-  });
-
-  upload.on('error', function(err) {
-    console.log('********** Upload error :', err)
-    return handleError(res, err);
-  });
-
-  upload.parse(req);
-};
-
-
-/**
- * Get my info
- */
-exports.me = function(req, res, next) {
-  var userId = req.user.id;
-
-  User
-    .findOne({
-      where: {
-        id: userId
-      },
-      attributes: ['id', 'fullname', 'name', 'email', 'role', 'userpic'],
-      include: [Module]
-    })
-    .then(function(user) {
-      if (!user) {
-        return res.sendStatus(401);
-      }
-      return res.status(200).send(user);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-/**
- * Update my user
- */
-exports.update = function(req, res, next) {
-  var userId = req.user.id;
-
-  User
-    .findById(req.params.id)
-    .then(function(user) {
-      if (user) {
-        user
-          .updateAttributes(req.body)
-          .then(function(user) {
-            return res.status(200).send(user);
-          })
-          .catch(function(err) {
-            return handleError(res, err);
-          });
-      } else {
-        return res.sendStatus(500);
-      }
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-/**
- * Get my avatar
- */
-exports.getAvatar = function(req, res, next) {
-  // var userId = req.params.id;
-
-  var imgPath = path.join(config.root, 'server', 'files', 'images', req.params.filename);
-
-  fs.exists(imgPath, function(exists) {
-    if (!exists) {
-      imgPath = path.join(config.root, 'server', 'files', 'images', 'userpic.png');
-    }
-
-    return res.sendFile(imgPath);
-  });
-};
-
-/**
- * Get my avatar by id
- */
-exports.getAvatarById = function(req, res, next) {
-
-  // console.log('getAvatarById');
-  // console.log(req.params);
-
-  if (req.params.id === 'visitor') {
-    var imgPath = path.join(config.root, 'server', 'files', 'images', 'customer.png');
-
-    fs.exists(imgPath, function(exists) {
-      return res.sendFile(imgPath);
-    });
-
-  } else {
-    User
-      .findById(req.params.id)
-      .then(function(user) {
-        if (user) {
-          var imgPath = path.join(config.root, 'server', 'files', 'images', user.userpic ? user.userpic : 'userpic.png');
-
-          fs.exists(imgPath, function(exists) {
-            if (!exists) {
-              imgPath = path.join(config.root, 'server', 'files', 'images', 'userpic.png');
-            }
-
-            return res.sendFile(imgPath);
-          });
-        } else {
-          return res.sendStatus(500);
-        }
-      })
-      .catch(function(err) {
-        return handleError(res, err);
-      });
-  }
-};
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function(req, res) {
-  User
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.userValidation = function(req, res) {
-  var where = {};
-  where[req.params.field] = req.body.value;
-  User
-    .findAndCountAll({
-      where: where
-    })
-    .then(function(result) {
-      if (result.count) {
-        return res.status(200).send({
-          isValid: false,
-          value: req.body.value
-        });
-      }
-      return res.status(200).send({
-        isValid: true,
-        value: req.body.value
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-
-};
-
-/**
- * Authentication callback
- */
-exports.authCallback = function(req, res, next) {
-  res.redirect('/');
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/user/user.socket.js b/server/api/user/user.socket.js
index e1071aa..db81dd7 100644
--- a/server/api/user/user.socket.js
+++ b/server/api/user/user.socket.js
@@ -1,31 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var user = require('../../models').User;
-
-exports.register = function(socket) {
-  user.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  user.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  user.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  if (doc.role === 'admin') {
-    socket.emit('user:save', doc);
-  }
-}
-
-function onRemove(socket, doc, cb) {
-  if (doc.role === 'admin') {
-    socket.emit('user:remove', doc);
-  }
-}
\ No newline at end of file
diff --git a/server/api/user/user.spec.js b/server/api/user/user.spec.js
index 485dee1..47de0aa 100644
--- a/server/api/user/user.spec.js
+++ b/server/api/user/user.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/users', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/users')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_chat_queue/index.js b/server/api/user_has_chat_queue/index.js
index bce94e7..ed71915 100644
--- a/server/api/user_has_chat_queue/index.js
+++ b/server/api/user_has_chat_queue/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./user_has_chat_queue.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_chat_queue/user_has_chat_queue.controller.js b/server/api/user_has_chat_queue/user_has_chat_queue.controller.js
index b399892..f7c88d6 100644
--- a/server/api/user_has_chat_queue/user_has_chat_queue.controller.js
+++ b/server/api/user_has_chat_queue/user_has_chat_queue.controller.js
@@ -1,103 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var UserHasChatQueue = require('../../models').UserHasChatQueue;
-
-// Get list of userHasChatQueues
-exports.index = function(req, res) {
-  UserHasChatQueue
-    .findAll(req.query ? {
-      where: req.query
-    } : {})
-    .then(function(userHasChatQueues) {
-      return res.status(200).send(userHasChatQueues);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single userHasChatQueue
-exports.show = function(req, res) {
-  UserHasChatQueue
-    .findById(req.params.id)
-    .then(function(userHasChatQueue) {
-      if (!userHasChatQueue) {
-        return res.sendStatus(404);
-      }
-      return res.send(userHasChatQueue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new userHasChatQueue in the DB.
-exports.create = function(req, res) {
-  UserHasChatQueue
-    .create(req.body)
-    .then(function(userHasChatQueue) {
-      return res.status(201).send(userHasChatQueue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing userHasChatQueue in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  UserHasChatQueue
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(userHasChatQueue) {
-      if (!userHasChatQueue) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(userHasChatQueue, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(userHasChatQueue);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a userHasChatQueue from the DB.
-exports.destroy = function(req, res) {
-  UserHasChatQueue
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(userHasChatQueue) {
-      if (!userHasChatQueue) {
-        return res.sendStatus(404);
-      }
-      userHasChatQueue.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/user_has_chat_queue/user_has_chat_queue.socket.js b/server/api/user_has_chat_queue/user_has_chat_queue.socket.js
index d760d5e..062ddb9 100644
--- a/server/api/user_has_chat_queue/user_has_chat_queue.socket.js
+++ b/server/api/user_has_chat_queue/user_has_chat_queue.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var UserHasChatQueue = require('../../models').UserHasChatQueue;
-
-exports.register = function(socket) {
-  UserHasChatQueue.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  UserHasChatQueue.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('user_has_chat_queue:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('user_has_chat_queue:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/user_has_chat_queue/user_has_chat_queue.spec.js b/server/api/user_has_chat_queue/user_has_chat_queue.spec.js
index 539163a..051c996 100644
--- a/server/api/user_has_chat_queue/user_has_chat_queue.spec.js
+++ b/server/api/user_has_chat_queue/user_has_chat_queue.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/chat/user_has_queues', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/chat/user_has_queues')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_chat_room/index.js b/server/api/user_has_chat_room/index.js
index 381448d..336789e 100644
--- a/server/api/user_has_chat_room/index.js
+++ b/server/api/user_has_chat_room/index.js
@@ -1,16 +1 @@
-'use strict';
-
-var express     = require('express');
-var controller  = require('./user_has_chat_room.controller');
-var auth        = require('../../auth/auth.service');
-
-var router = express.Router();
-
-// router.get('/', controller.index);
-// router.get('/:id', controller.show);
-// router.post('/', controller.create);
-router.put('/:userId/:chatRoomId', controller.update);
-// router.patch('/:id', controller.update);
-// router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/user_has_chat_room/user_has_chat_room.controller.js b/server/api/user_has_chat_room/user_has_chat_room.controller.js
index d747380..fdf190d 100644
--- a/server/api/user_has_chat_room/user_has_chat_room.controller.js
+++ b/server/api/user_has_chat_room/user_has_chat_room.controller.js
@@ -1,96 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var UserHasChatRoom = require('../../models').UserHasChatRoom;
-
-// Get list of user_has_chat_rooms
-exports.index = function(req, res) {
-  UserHasChatRoom
-  .findAll()
-  .then(function (user_has_chat_rooms) {
-    return res.status(200).send(user_has_chat_rooms);
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-// Get a single user_has_chat_room
-exports.show = function(req, res) {
-  UserHasChatRoom
-  .findById(req.params.id)
-  .then(function (user_has_chat_room) {
-    if(!user_has_chat_room) { return res.sendStatus(404); }
-    return res.send(user_has_chat_room);
-  })
-  .catch(function(err){
-    return handleError(res, err);
-  });
-};
-
-// Creates a new user_has_chat_room in the DB.
-exports.create = function(req, res) {
-
-  UserHasChatRoom
-    .create(req.body)
-    .then(function(user_has_chat_room) {
-      return res.status(201).send(user_has_chat_room);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing user_has_chat_room in the DB.
-exports.update = function(req, res) {
-
-  UserHasChatRoom
-    .findOne({
-      where: {
-        UserId: req.params.userId,
-        ChatRoomId: req.params.chatRoomId
-      },
-      limit: 1
-    })
-    .then(function (user_has_chat_room) {
-      if (!user_has_chat_room) {
-        return res.sendStatus(404);
-      }
-
-      user_has_chat_room
-        .updateAttributes(req.body)
-        .then(function () {
-          return res.status(200).send(user_has_chat_room);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a user_has_chat_room from the DB.
-exports.destroy = function(req, res) {
-
-  UserHasChatRoom
-  .findById(req.params.id)
-  .then(function (user_has_chat_room) {
-    if(!user_has_chat_room) { return res.sendStatus(404); }
-    user_has_chat_room.destroy()
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-  })
-  .catch(function(err) {
-    return handleError(res, err);
-  });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/user_has_chat_room/user_has_chat_room.socket.js b/server/api/user_has_chat_room/user_has_chat_room.socket.js
index c58a829..c7f7af6 100644
--- a/server/api/user_has_chat_room/user_has_chat_room.socket.js
+++ b/server/api/user_has_chat_room/user_has_chat_room.socket.js
@@ -1,58 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-var _ = require('lodash');
-var User = require('../../models').User;
-var ChatRoom = require('../../models').ChatRoom;
-var ChatVisitor = require('../../models').ChatVisitor;
-var UserHasChatRoom = require('../../models').UserHasChatRoom;
-
-exports.register = function (socket) {
-  UserHasChatRoom.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  UserHasChatRoom.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc) {
-
-  var _chatRoom;
-
-  return ChatRoom
-    .findById(doc.ChatRoomId, {
-      include: [{
-        model: ChatVisitor,
-        attributes: ['id', 'email', 'fullname']
-      }, {
-        model: User,
-        attributes: ['id', 'email', 'name', 'fullname']
-      }]
-    })
-    .then(function (chatRoom) {
-      _chatRoom = chatRoom;
-      _chatRoom.dataValues.ChatMessages = [];
-
-      console.log('_chatRoom', _chatRoom);
-
-      var ids = _.pluck(_chatRoom.Users, 'id');
-
-      ids.forEach(function (id) {
-        if (socket.userId == id) {
-          socket.emit('user_has_chat_room:save', _chatRoom.dataValues)
-        }
-      });
-
-      return;
-    })
-    .catch(function (err) {
-      console.error(err);
-    });
-}
-
-function onRemove(socket, doc) {
-  socket.emit('user_has_chat_room:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/user_has_chat_room/user_has_chat_room.spec.js b/server/api/user_has_chat_room/user_has_chat_room.spec.js
index b33382a..a45ca65 100644
--- a/server/api/user_has_chat_room/user_has_chat_room.spec.js
+++ b/server/api/user_has_chat_room/user_has_chat_room.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/chat/user_has_rooms', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/chat/user_has_rooms')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_fax_queue/index.js b/server/api/user_has_fax_queue/index.js
index 5805e3d..ef6e636 100644
--- a/server/api/user_has_fax_queue/index.js
+++ b/server/api/user_has_fax_queue/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./user_has_fax_queue.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_fax_queue/user_has_fax_queue.controller.js b/server/api/user_has_fax_queue/user_has_fax_queue.controller.js
index f92e570..3c02222 100644
--- a/server/api/user_has_fax_queue/user_has_fax_queue.controller.js
+++ b/server/api/user_has_fax_queue/user_has_fax_queue.controller.js
@@ -1,103 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var UserHasFaxQueue = require('../../models').UserHasFaxQueue;
-
-// Get list of user_has_fax_queues
-exports.index = function(req, res) {
-  UserHasFaxQueue
-    .findAll(req.query ? {
-      where: req.query
-    } : {})
-    .then(function(user_has_fax_queues) {
-      return res.status(200).send(user_has_fax_queues);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single user_has_fax_queue
-exports.show = function(req, res) {
-  UserHasFaxQueue
-    .findById(req.params.id)
-    .then(function(user_has_fax_queue) {
-      if (!user_has_fax_queue) {
-        return res.sendStatus(404);
-      }
-      return res.send(user_has_fax_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new user_has_fax_queue in the DB.
-exports.create = function(req, res) {
-  UserHasFaxQueue
-    .create(req.body)
-    .then(function(user_has_fax_queue) {
-      return res.status(201).send(user_has_fax_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing user_has_fax_queue in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  UserHasFaxQueue
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(user_has_fax_queue) {
-      if (!user_has_fax_queue) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(user_has_fax_queue, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(user_has_fax_queue);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a user_has_fax_queue from the DB.
-exports.destroy = function(req, res) {
-  UserHasFaxQueue
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(user_has_fax_queue) {
-      if (!user_has_fax_queue) {
-        return res.sendStatus(404);
-      }
-      user_has_fax_queue.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/user_has_fax_queue/user_has_fax_queue.socket.js b/server/api/user_has_fax_queue/user_has_fax_queue.socket.js
index 4b0602a..a5222b7 100644
--- a/server/api/user_has_fax_queue/user_has_fax_queue.socket.js
+++ b/server/api/user_has_fax_queue/user_has_fax_queue.socket.js
@@ -1,30 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var UserHasFaxQueue = require('../../models').UserHasFaxQueue;
-
-exports.register = function(socket) {
-  UserHasFaxQueue.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  UserHasFaxQueue.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-  UserHasFaxQueue.afterBulkCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  UserHasFaxQueue.afterBulkDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('user_has_fax_queue:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('user_has_fax_queue:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/user_has_fax_queue/user_has_fax_queue.spec.js b/server/api/user_has_fax_queue/user_has_fax_queue.spec.js
index 992672c..75ea7b2 100644
--- a/server/api/user_has_fax_queue/user_has_fax_queue.spec.js
+++ b/server/api/user_has_fax_queue/user_has_fax_queue.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/fax/user_has_queues', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/fax/user_has_queues')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_mail_queue/index.js b/server/api/user_has_mail_queue/index.js
index 50b083e..c2e1a29 100644
--- a/server/api/user_has_mail_queue/index.js
+++ b/server/api/user_has_mail_queue/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./user_has_mail_queue.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/user_has_mail_queue/user_has_mail_queue.controller.js b/server/api/user_has_mail_queue/user_has_mail_queue.controller.js
index c15bc9d..2606740 100644
--- a/server/api/user_has_mail_queue/user_has_mail_queue.controller.js
+++ b/server/api/user_has_mail_queue/user_has_mail_queue.controller.js
@@ -1,95 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var UserHasMailQueue = require('../../models').UserHasMailQueue;
-
-// Get list of user_has_mail_queues
-exports.index = function(req, res) {
-  UserHasMailQueue
-    .findAll(req.query ? {
-      where: req.query
-    } : {})
-    .then(function(user_has_mail_queues) {
-      return res.status(200).send(user_has_mail_queues);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single user_has_mail_queue
-exports.show = function(req, res) {
-  UserHasMailQueue
-    .findById(req.params.id)
-    .then(function(user_has_mail_queue) {
-      if (!user_has_mail_queue) {
-        return res.sendStatus(404);
-      }
-      return res.send(user_has_mail_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new user_has_mail_queue in the DB.
-exports.create = function(req, res) {
-  UserHasMailQueue
-    .create(req.body)
-    .then(function(user_has_mail_queue) {
-      return res.status(201).send(user_has_mail_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing user_has_mail_queue in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  UserHasMailQueue
-    .findById(req.params.id)
-    .then(function(user_has_mail_queue) {
-      if (!user_has_mail_queue) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(user_has_mail_queue, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(user_has_mail_queue);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a user_has_mail_queue from the DB.
-exports.destroy = function(req, res) {
-  UserHasMailQueue
-    .findById(req.params.id)
-    .then(function(user_has_mail_queue) {
-      if (!user_has_mail_queue) {
-        return res.sendStatus(404);
-      }
-      user_has_mail_queue.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/user_has_mail_queue/user_has_mail_queue.socket.js b/server/api/user_has_mail_queue/user_has_mail_queue.socket.js
index bea513c..d95cb77 100644
--- a/server/api/user_has_mail_queue/user_has_mail_queue.socket.js
+++ b/server/api/user_has_mail_queue/user_has_mail_queue.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var UserHasMailQueue = require('../../models').UserHasMailQueue;
-
-exports.register = function(socket) {
-  UserHasMailQueue.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  UserHasMailQueue.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('user_has_mail_queue:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('user_has_mail_queue:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/user_has_mail_queue/user_has_mail_queue.spec.js b/server/api/user_has_mail_queue/user_has_mail_queue.spec.js
index d516012..6a48f06 100644
--- a/server/api/user_has_mail_queue/user_has_mail_queue.spec.js
+++ b/server/api/user_has_mail_queue/user_has_mail_queue.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/mail/user_has_queues', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/mail/user_has_queues')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_team/index.js b/server/api/user_has_team/index.js
index 723bdc1..1d4d6ec 100644
--- a/server/api/user_has_team/index.js
+++ b/server/api/user_has_team/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./user_has_team.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_team/user_has_team.controller.js b/server/api/user_has_team/user_has_team.controller.js
index 7f0f426..6d2be5f 100644
--- a/server/api/user_has_team/user_has_team.controller.js
+++ b/server/api/user_has_team/user_has_team.controller.js
@@ -1,96 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var UserHasTeam = require('../../models').UserHasTeam;
-
-// Get list of user_has_teams
-exports.index = function(req, res) {
-  console.log(req.query);
-  UserHasTeam
-    .findAll({
-      where: req.query
-    })
-    .then(function(user_has_teams) {
-      return res.status(200).send(user_has_teams);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single user_has_team
-exports.show = function(req, res) {
-  UserHasTeam
-    .findById(req.params.id)
-    .then(function(user_has_team) {
-      if (!user_has_team) {
-        return res.sendStatus(404);
-      }
-      return res.send(user_has_team);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new user_has_team in the DB.
-exports.create = function(req, res) {
-  UserHasTeam
-    .create(req.body)
-    .then(function(user_has_team) {
-      return res.status(201).send(user_has_team);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing user_has_team in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  UserHasTeam
-    .findById(req.params.id)
-    .then(function(user_has_team) {
-      if (!user_has_team) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(user_has_team, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(user_has_team);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a user_has_team from the DB.
-exports.destroy = function(req, res) {
-  UserHasTeam
-    .findById(req.params.id)
-    .then(function(user_has_team) {
-      if (!user_has_team) {
-        return res.sendStatus(404);
-      }
-      user_has_team.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/user_has_team/user_has_team.model.js b/server/api/user_has_team/user_has_team.model.js
index 6d5861d..87afe73 100644
--- a/server/api/user_has_team/user_has_team.model.js
+++ b/server/api/user_has_team/user_has_team.model.js
@@ -1,13 +1 @@
-'use strict';
-
-module.export = function(sequelize, DataTypes) {
-
-  var UserHasTeam = sequelize.define('UserHasTeam', {
-    name: String,
-    info: String,
-    active: Boolean
-  });
-
-  return UserHasTeam;
-
-};
+var _0x2635=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74","\x55\x73\x65\x72\x48\x61\x73\x54\x65\x61\x6D","\x64\x65\x66\x69\x6E\x65"];_0x2635[0];module[_0x2635[1]]=function(_0xf339x1,_0xf339x2){var _0xf339x3=_0xf339x1[_0x2635[3]](_0x2635[2],{name:String,info:String,active:Boolean});return _0xf339x3;};
\ No newline at end of file
diff --git a/server/api/user_has_team/user_has_team.socket.js b/server/api/user_has_team/user_has_team.socket.js
index 879043c..6747225 100644
--- a/server/api/user_has_team/user_has_team.socket.js
+++ b/server/api/user_has_team/user_has_team.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var user_has_team = require('../../models').UserHasTeam;
-
-exports.register = function(socket) {
-  user_has_team.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  user_has_team.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('user_has_team:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('user_has_team:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/user_has_team/user_has_team.spec.js b/server/api/user_has_team/user_has_team.spec.js
index 5cc5226..ce86646 100644
--- a/server/api/user_has_team/user_has_team.spec.js
+++ b/server/api/user_has_team/user_has_team.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/user_has_teams', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/user_has_teams')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_voice_queue/index.js b/server/api/user_has_voice_queue/index.js
index 72551d5..e734269 100644
--- a/server/api/user_has_voice_queue/index.js
+++ b/server/api/user_has_voice_queue/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./user_has_voice_queue.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/user_has_voice_queue/user_has_voice_queue.controller.js b/server/api/user_has_voice_queue/user_has_voice_queue.controller.js
index f3e5d22..4ecb993 100644
--- a/server/api/user_has_voice_queue/user_has_voice_queue.controller.js
+++ b/server/api/user_has_voice_queue/user_has_voice_queue.controller.js
@@ -1,98 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var UserHasVoiceQueue = require('../../models').UserHasVoiceQueue;
-
-// Get list of user_has_voice_queues
-exports.index = function(req, res) {
-  UserHasVoiceQueue
-    .findAll(req.query ? {
-      where: req.query
-    } : {})
-    .then(function(user_has_voice_queues) {
-      return res.status(200).send(user_has_voice_queues);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single userHasVoiceQueue
-exports.show = function(req, res) {
-  UserHasVoiceQueue
-    .findById(req.params.id)
-    .then(function(userHasVoiceQueue) {
-      if (!userHasVoiceQueue) {
-        return res.sendStatus(404);
-      }
-      return res.send(userHasVoiceQueue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new userHasVoiceQueue in the DB.
-exports.create = function(req, res, next) {
-  console.log(req.body);
-  UserHasVoiceQueue
-    .create(req.body)
-    .then(function(userHasVoiceQueue) {
-      return res.status(201).send(userHasVoiceQueue);
-    })
-    .catch(function(err) {
-      console.error(err);
-      return next(err);
-      // return handleError(res, err);
-    });
-};
-
-// Updates an existing userHasVoiceQueue in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  UserHasVoiceQueue
-    .findById(req.params.id)
-    .then(function(userHasVoiceQueue) {
-      if (!userHasVoiceQueue) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(userHasVoiceQueue, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(userHasVoiceQueue);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a userHasVoiceQueue from the DB.
-exports.destroy = function(req, res) {
-  UserHasVoiceQueue
-    .findById(req.params.id)
-    .then(function(userHasVoiceQueue) {
-      if (!userHasVoiceQueue) {
-        return res.sendStatus(404);
-      }
-      userHasVoiceQueue.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/user_has_voice_queue/user_has_voice_queue.socket.js b/server/api/user_has_voice_queue/user_has_voice_queue.socket.js
index 73e229c..1cfa1df 100644
--- a/server/api/user_has_voice_queue/user_has_voice_queue.socket.js
+++ b/server/api/user_has_voice_queue/user_has_voice_queue.socket.js
@@ -1,41 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var UserHasVoiceQueue = require('../../models').UserHasVoiceQueue;
-
-exports.register = function(socket) {
-  UserHasVoiceQueue.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  UserHasVoiceQueue.afterUpdate(function(doc) {
-    onSave(socket, doc);
-  });
-  UserHasVoiceQueue.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('user_has_voice_queue:save', {
-    logged: doc.logged,
-    loggedAt: doc.loggedAt,
-    queue: doc.queue,
-    membername: doc.membername,
-    interface: doc.interface,
-    callstaken: doc.callstaken,
-    lastcall: doc.lastcall,
-    status: doc.status,
-    statusdesc: doc.statusdesc,
-    statusAt: doc.statusAt,
-    paused: doc.paused,
-    pausedAt: doc.pausedAt,
-    reason: doc.reason
-  });
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('user_has_voice_queue:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/user_has_voice_queue/user_has_voice_queue.spec.js b/server/api/user_has_voice_queue/user_has_voice_queue.spec.js
index 0ac501f..0ee1487 100644
--- a/server/api/user_has_voice_queue/user_has_voice_queue.spec.js
+++ b/server/api/user_has_voice_queue/user_has_voice_queue.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/voice/user_has_queues', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/voice/user_has_queues')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/variable/index.js b/server/api/variable/index.js
index c2fafbf..57b5f15 100644
--- a/server/api/variable/index.js
+++ b/server/api/variable/index.js
@@ -1,18 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./variable.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.variableValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/variable/variable.controller.js b/server/api/variable/variable.controller.js
index 5cd10db..67f1f9a 100644
--- a/server/api/variable/variable.controller.js
+++ b/server/api/variable/variable.controller.js
@@ -1,220 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Variable = require('../../models').Variable;
-var util = require('util');
-
-// Get list of variables
-exports.index = function(req, res) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  Variable
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-exports.variableValidation = function(req, res) {
-  console.log(req.body);
-  Variable
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(variables) {
-      if (!variables) {
-        return res.sendStatus(404);
-      }
-      return res.send(variables);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single variable
-exports.show = function(req, res) {
-  Variable
-    .findById(req.params.id)
-    .then(function(variable) {
-      if (!variable) {
-        return res.sendStatus(404);
-      }
-      return res.send(variable);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new variable in the DB.
-exports.create = function(req, res) {
-  Variable
-    .create(req.body)
-    .then(function(variable) {
-      return res.status(201).send(variable);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing variable in the DB.
-exports.update = function(req, res) {
-  Variable
-    .findAll({
-      where: {
-        name: req.body.name,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function(variables) {
-      if (!variables) {
-        return res.sendStatus(404);
-      }
-      if (variables.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_VARIABLE'
-        })
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      Variable
-        .find({
-          where: {
-            id: req.params.id
-          }
-        })
-        .then(function(variable) {
-          if (!variable) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(variable, req.body);
-          updated.save()
-            .then(function() {
-              return res.status(200).send(variable);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a variable from the DB.
-exports.destroy = function(req, res) {
-  Variable
-    .findById(req.params.id)
-    .then(function(variable) {
-      if (!variable) {
-        return res.sendStatus(404);
-      }
-      variable.getZendeskTexts()
-        .then(function(texts) {
-          if (texts.length > 0) {
-            return res.status(500).send({
-              message: 'MESSAGE_VARIABLE_CONFIGURATION_ASSOCIATED'
-            });
-          }
-          variable.destroy()
-            .then(function() {
-              return res.sendStatus(204);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.bulkDestroy = function(req, res) {
-  Variable
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/variable/variable.socket.js b/server/api/variable/variable.socket.js
index 739f11c..209fae8 100644
--- a/server/api/variable/variable.socket.js
+++ b/server/api/variable/variable.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var Variable = require('../../models').Variable;
-
-exports.register = function(socket) {
-  Variable.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  Variable.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('variable:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('variable:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/variable/variable.spec.js b/server/api/variable/variable.spec.js
index 0a463f7..eb1ca0b 100644
--- a/server/api/variable/variable.spec.js
+++ b/server/api/variable/variable.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/variables', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/variables')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/api/voice_context/index.js b/server/api/voice_context/index.js
index 1b436c8..02f3ea2 100644
--- a/server/api/voice_context/index.js
+++ b/server/api/voice_context/index.js
@@ -1,16 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./voice_context.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.contextValidation);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/voice_context/voice_context.ami.js b/server/api/voice_context/voice_context.ami.js
index a8737f4..f18e3d3 100644
--- a/server/api/voice_context/voice_context.ami.js
+++ b/server/api/voice_context/voice_context.ami.js
@@ -1,71 +1 @@
-'use strict';
-
-var VoiceContext = require('../../models').VoiceContext;
-var fs = require('fs');
-var util = require('util');
-var path = require('path');
-var config = require('../../config/environment');
-
-exports.register = function(ami) {
-  VoiceContext.beforeUpdate(function(updatedContext) {
-    if (updatedContext.changed('name')) {
-      throw new Error("You can't modify a context name");
-    }
-    if (updatedContext.defaultEntry) {
-      throw new Error("You can't modify a default context");
-    }
-  });
-
-  VoiceContext.beforeDelete(function(context) {
-    if (context.defaultEntry) {
-      throw new Error("You can't delete a default context");
-    }
-  });
-
-  VoiceContext.afterCreate(function(doc) {
-    rewriteContexts(doc, ami, false);
-  })
-
-  VoiceContext.afterDelete(function(doc) {
-    rewriteContexts(doc, ami, true);
-  })
-}
-
-function rewriteContexts(doc, ami, deleteContext) {
-  var contextValues = '';
-  if (!deleteContext) {
-    contextValues = util.format('[%s]\nswitch => Realtime\n', doc.name);
-  }
-  VoiceContext
-    .findAll({
-      where: {
-        id: {
-          $ne: doc.id
-        }
-      }
-    })
-    .then(function(contexts) {
-      contexts.forEach(function(element) {
-        contextValues += util.format('[%s]\nswitch => Realtime\n', element.name);
-      });
-      fs.writeFile(path.join(config.root, 'server/files/asterisk/sip_xcally_contexts.conf'), contextValues, {
-        flags: 'w',
-        mode: parseInt('0777', 8)
-      }, function(err) {
-        if (err) throw err;
-        console.log("Contexts file saved!");
-        ami.action({
-          Action: 'Reload',
-        }, function(err, res) {
-          if (err) {
-            console.error(err);
-          } else {
-            console.log(res);
-          }
-        });
-      });
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
\ No newline at end of file
diff --git a/server/api/voice_context/voice_context.controller.js b/server/api/voice_context/voice_context.controller.js
index 662a803..06bb6dc 100644
--- a/server/api/voice_context/voice_context.controller.js
+++ b/server/api/voice_context/voice_context.controller.js
@@ -1,282 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var sequelize = require('../../models').sequelize;
-
-var VoiceContext = require('../../models').VoiceContext;
-var VoiceExtension = require('../../models').VoiceExtension;
-
-// Get list of agents
-exports.index = function(req, res, next) {
-
-  var attributes = ['name', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  VoiceContext
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single voice_context
-exports.show = function(req, res) {
-  VoiceContext
-    .findById(req.params.id)
-    .then(function(voice_context) {
-      if (!voice_context) {
-        return res.sendStatus(404);
-      }
-      return res.send(voice_context);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Validate the existence of a context
-exports.contextValidation = function(req, res) {
-  console.log(req.body);
-  VoiceContext
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(voice_contexts) {
-      if (!voice_contexts) {
-        return res.sendStatus(404);
-      }
-      return res.send(voice_contexts);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new voice_context in the DB.
-exports.create = function(req, res) {
-  VoiceContext
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(existingContexts) {
-      console.log(existingContexts);
-      console.log('Finding app row.....');
-      if (!existingContexts) {
-        return res.sendStatus(404);
-      }
-      if (existingContexts.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_ROUTE'
-        });
-      }
-      VoiceContext
-        .create(req.body)
-        .then(function(voice_context) {
-          return res.status(201).send(voice_context);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-
-};
-
-// Updates an existing voice_context in the DB.
-exports.update = function(req, res) {
-  VoiceContext
-    .findAll({
-      where: {
-        name: req.body.name,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function(existingContexts) {
-      console.log(existingContexts);
-      console.log('Finding app row.....');
-      if (!existingContexts) {
-        return res.sendStatus(404);
-      }
-      if (existingContexts.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_ROUTE'
-        });
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      VoiceContext
-        .findById(req.params.id)
-        .then(function(voice_context) {
-          if (!voice_context) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(voice_context, req.body);
-          updated.save()
-            .then(function() {
-              return res.status(200).send(voice_context);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-
-};
-
-// Deletes a voice_context from the DB.
-exports.destroy = function(req, res) {
-  VoiceContext
-    .findById(req.params.id)
-    .then(function(voice_context) {
-      if (!voice_context) {
-        return res.sendStatus(404);
-      }
-      VoiceExtension
-        .findAll({
-          where: {
-            context: voice_context.name
-          }
-        })
-        .then(function(contextExtensions) {
-          if (contextExtensions.length > 0) {
-            return res.status(500).send({
-              message: 'MESSAGE_CONTEXT_ROUTE_ASSOCIATED'
-            });
-          }
-          voice_context.destroy()
-            .then(function() {
-              return res.sendStatus(204);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a context from the DB.
-exports.bulkDestroy = function(req, res) {
-  VoiceContext
-    .findAll({
-      where: {
-        id: req.query.id
-      }
-    })
-    .then(function(voice_contexts) {
-      if (!voice_contexts) {
-        return res.sendStatus(404);
-      }
-      var destroyContextsNames = _.pluck(_.pluck(voice_contexts, 'dataValues'), 'name');
-      VoiceExtension
-        .findAll({
-          where: {
-            context: destroyContextsNames
-          }
-        })
-        .then(function(contextExtensions) {
-          if (contextExtensions.length > 0) {
-            return res.status(500).send({
-              message: 'MESSAGE_CONTEXT_ROUTE_ASSOCIATED'
-            });
-          }
-          VoiceContext
-            .destroy({
-              where: {
-                id: req.query.id
-              },
-              individualHooks: true
-            })
-            .then(function() {
-              return res.sendStatus(204);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/voice_context/voice_context.socket.js b/server/api/voice_context/voice_context.socket.js
index c3841ec..f0be6b1 100644
--- a/server/api/voice_context/voice_context.socket.js
+++ b/server/api/voice_context/voice_context.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var VoiceContext = require('../../models').VoiceContext;
-
-exports.register = function(socket) {
-  VoiceContext.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  VoiceContext.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('voice_context:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('voice_context:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/voice_context/voice_context.spec.js b/server/api/voice_context/voice_context.spec.js
index 1a60777..4ae7f0b 100644
--- a/server/api/voice_context/voice_context.spec.js
+++ b/server/api/voice_context/voice_context.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/voice/contexts', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/voice/contexts')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/voice_extension/index.js b/server/api/voice_extension/index.js
index cf428d7..18f9dbb 100644
--- a/server/api/voice_extension/index.js
+++ b/server/api/voice_extension/index.js
@@ -1,22 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./voice_extension.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/route/:route', auth.isAuthenticated(), controller.showByRoute);
-router.get('/applications/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id/applications', auth.isAuthenticated(), controller.showAppsByRoute);
-router.post('/validate', auth.isAuthenticated(), controller.routeValidation);
-router.post('/:id/applications', auth.isAuthenticated(), controller.sortAppsByRoute);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.put('/applications/:id', auth.isAuthenticated(), controller.updateApplication);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/voice_extension/voice_extension.controller.js b/server/api/voice_extension/voice_extension.controller.js
index 9701d40..053f1ba 100644
--- a/server/api/voice_extension/voice_extension.controller.js
+++ b/server/api/voice_extension/voice_extension.controller.js
@@ -1,1348 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var VoiceExtension = require('../../models').VoiceExtension;
-var Interval = require('../../models').Interval;
-var sequelize = require('../../models').sequelize;
-var Sequelize = require('../../models').Sequelize;
-var util = require('util');
-var async = require('async');
-
-var Applications = {
-  Dial: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Set',
-    appdata: 'CALLERID(all)=%s'
-  }, {
-    app: 'Dial',
-    appdata: '%s,%s,%s,%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Dial Application End'
-  }],
-  Queue: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Answer',
-    appdata: ''
-  }, {
-    app: 'Queue',
-    appdata: '%s,%s,%s,%s,%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Queue Application End'
-  }],
-  Playback: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Playback',
-    appdata: '%s,%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Playback Application End'
-  }],
-  AGI: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'AGI',
-    appdata: 'agi://127.0.0.1/square,%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'AGI Application End'
-  }],
-  Goto: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Goto',
-    appdata: '%s,%s,%d',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Goto Application End'
-  }],
-  Hangup: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Hangup',
-    appdata: '%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Hangup Application End'
-  }],
-  Set: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Set',
-    appdata: '%s=%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Set Application End'
-  }],
-  custom: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'custom',
-    appdata: '%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Custom Application End'
-  }],
-  Voicemail: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Voicemail',
-    appdata: '%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Voicemail Application End'
-  }]
-};
-
-// Get list of voice_extensions
-exports.index = function (req, res) {
-  VoiceExtension
-    .findAll()
-    .then(function (voice_extensions) {
-      return res.status(200).send(voice_extensions);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get list of agents
-exports.showByRoute = function (req, res, next) {
-
-  var attributes = ['context', 'exten', 'app', 'appdata'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {
-      type: req.params.route,
-      VoiceExtensionId: null,
-      app: 'NoOp'
-    },
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function (value, key) {
-    switch (key) {
-    case 'per_page':
-    case 'page':
-      break;
-    case 'sort_by':
-      query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-      break;
-    case 'sort_order':
-      break;
-    case '$':
-      query.where.$or = [];
-      attributes.forEach(function (attribute) {
-        var tmp = {};
-        tmp[attribute] = {
-          $like: '%' + value + '%'
-        };
-
-        query.where.$or.push(tmp);
-      });
-      break;
-    default:
-      query.where[key] = {
-        $like: {}
-      };
-      query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  VoiceExtension
-    .findAndCountAll(query)
-    .then(function (result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function (err) {
-      res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-
-// Get list of voice_extensions by route
-exports.showAppsByRoute = function (req, res) {
-  VoiceExtension
-    .findAll({
-      where: {
-        VoiceExtensionId: req.params.id,
-        isApp: true
-      }
-    })
-    .then(function (voice_extensions) {
-      return res.status(200).send(voice_extensions);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single voice_extension or application
-exports.show = function (req, res) {
-  VoiceExtension
-    .findById(req.params.id)
-    .then(function (voice_extension) {
-      if (!voice_extension) {
-        return res.sendStatus(404);
-      }
-      return res.send(voice_extension);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Validate the existence of a route
-exports.routeValidation = function (req, res) {
-  VoiceExtension
-    .findAll({
-      where: {
-        exten: req.body.exten,
-        context: req.body.context,
-        type: req.body.type
-      }
-    })
-    .then(function (voice_extension) {
-      if (!voice_extension) {
-        return res.sendStatus(404);
-      }
-      return res.send(voice_extension);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// exports.sortAppsByRoute = function(req, res, next) {
-//   return sequelize
-//     .transaction()
-//     .then(function(t) {
-//       async.waterfall([
-//           function(callback) {
-//             VoiceExtension
-//               .findAll({
-//                 where: {
-//                   appGroup: req.body.applications
-//                 }
-//               })
-//               .then(function(voiceApplications) {
-//                 callback(null, voiceApplications);
-//               })
-//               .catch(function(err) {
-//                 callback(err);
-//               });
-//           },
-//           function(voiceApplications, callback) {
-//             console.log('found ad saved applications');
-//             console.log('destroying old applications from db');
-//             return VoiceExtension.destroy({
-//                 where: {
-//                   appGroup: req.body.applications
-//                 }
-//               }, {
-//                 transaction: t
-//               })
-//               .then(function() {
-//                 callback(null, voiceApplications);
-//               })
-//               .catch(function(err) {
-//                 callback(err);
-//               });
-//           },
-//           function(voiceApplications, callback) {
-//             console.log('destroyed old applications from db');
-//             var priority = 2;
-//             console.log('iterating sorted applications ids');
-//             req.body.applications.forEach(function(sortedElem) {
-//               var tmpElem = _.find(voiceApplications, function(elem) {
-//                 return (elem.appGroup == sortedElem && elem.isApp === true);
-//               });
-//               var application = _.cloneDeep(Applications[tmpElem.app]);
-//               if (!application || tmpElem.customApp) {
-//                 application = [{
-//                   app: 'GotoIfTime',
-//                   appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-//                 }, {
-//                   app: 'custom',
-//                   appdata: '%s',
-//                   isApp: true
-//                 }, {
-//                   app: 'NoOp',
-//                   appdata: 'Custom Application End'
-//                 }];
-//               }
-//               //console.log('PRIORITY');
-//               //console.log(priority);
-//               var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority);
-//               tmpElem.interval = tmpElem.interval || '*,*,*,*';
-//               var tmpIntervals = _.filter(voiceApplications, function(elem) {
-//                 return (elem.appGroup == sortedElem && elem.isInterval === true);
-//               });
-//               if (tmpIntervals && tmpIntervals.length > 0) {
-//                 console.log('found custom interval, adding to app');
-//                 application.splice(0, 1);
-//                 tmpIntervals.forEach(function(elem, index) {
-//
-//                   application.unshift({
-//                     app: 'GotoIfTimeFromArray',
-//                     appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s',
-//                     IntervalId: elem.IntervalId ? elem.IntervalId : null,
-//                     isInterval: true,
-//                     interval: elem.interval,
-//                   });
-//                 })
-//               }
-//               priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority);
-//               //console.log('returned priority');
-//               //console.log(priority);
-//               console.log('creating group of extensions');
-//               return VoiceExtension
-//                 .bulkCreate(application, {
-//                   transaction: t
-//                 })
-//             });
-//             callback();
-//           }
-//         ],
-//         function(err, result) {
-//           if (err) {
-//             console.log(err);
-//             t.rollback();
-//           } else {
-//             console.log('commit');
-//             t.commit();
-//             console.log('finished creating, now searching the sorted and saved apps');
-//             VoiceExtension
-//               .findAll({
-//                 where: {
-//                   VoiceExtensionId: req.params.id,
-//                   isApp: true
-//                 }
-//               })
-//               .then(function(voiceExtensions) {
-//                 console.log('found sorted applications, returning');
-//                 //console.log(_.pluck(voiceExtensions, 'dataValues'));
-//                 return res.status(201).send(voiceExtensions);
-//               })
-//           }
-//         });
-//     });
-// }
-
-exports.sortAppsByRoute = function (req, res, next) {
-  // console.log('finding and saving old applications');
-  VoiceExtension
-    .findAll({
-      where: {
-        appGroup: req.body.applications
-      }
-    })
-    .then(function (voiceApplications) {
-      // console.log('found ad saved applications');
-      return sequelize.transaction(function (t) {
-          // console.log('destroying old applications from db');
-          return VoiceExtension.destroy({
-              where: {
-                appGroup: req.body.applications
-              }
-            }, {
-              transaction: t
-            })
-            .then(function () {
-              var priority = 2;
-              req.body.applications.forEach(function (sortedElem) {
-                var tmpElem = _.find(voiceApplications, function (elem) {
-                  return (elem.appGroup == sortedElem && elem.isApp === true);
-                });
-                var application = _.cloneDeep(Applications[tmpElem.app]);
-                if (!application || tmpElem.customApp) {
-                  application = [{
-                    app: 'GotoIfTime',
-                    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                  }, {
-                    app: 'custom',
-                    appdata: '%s',
-                    isApp: true
-                  }, {
-                    app: 'NoOp',
-                    appdata: 'Custom Application End'
-                  }];
-                }
-                var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority);
-                tmpElem.interval = tmpElem.interval || '*,*,*,*';
-                var tmpIntervals = _.filter(voiceApplications, function (elem) {
-                  return (elem.appGroup == sortedElem && elem.isInterval === true);
-                });
-                if (tmpIntervals && tmpIntervals.length > 0) {
-                  // console.log('found custom interval, adding to app');
-                  application.splice(0, 1);
-                  tmpIntervals.forEach(function (elem, index) {
-
-                    application.unshift({
-                      app: 'GotoIfTimeFromArray',
-                      appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                      IntervalId: elem.IntervalId ? elem.IntervalId : null,
-                      isInterval: true,
-                      interval: elem.interval,
-                    });
-                  })
-                }
-                priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority);
-                //console.log('returned priority');
-                //console.log(priority);
-                // console.log('creating group of extensions');
-                return VoiceExtension
-                  .bulkCreate(application, {
-                    transaction: t
-                  })
-              });
-            })
-        })
-        .then(function () {
-          // console.log('finished creating, now searching the sorted and saved apps');
-          // VoiceExtension
-          //   .findAll({
-          //     where: {
-          //       VoiceExtensionId: req.params.id,
-          //       isApp: true
-          //     }
-          //   })
-          //   .then(function(voiceExtensions) {
-          //     console.log('found sorted applications, returning');
-          //     //console.log(_.pluck(voiceExtensions, 'dataValues'));
-          //     return res.status(201).send(voiceExtensions);
-          //   })
-          return res.sendStatus(201);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// // Creates a new voice_extension in the DB.
-// exports.create = function(req, res) {
-//   VoiceExtension
-//     .create(req.body)
-//     .then(function(voice_extension) {
-//       return res.status(201).send(voice_extension);
-//     })
-//     .catch(function(err) {
-//       return handleError(res, err);
-//     });
-// };
-
-// Creates a new voiceApplication in the DB.
-exports.create = function (req, res, next) {
-  // //console.log(req.body);
-  var application;
-  var appGroup;
-  var interval;
-  VoiceExtension
-    .max('priority', {
-      where: {
-        VoiceExtensionId: req.body.VoiceExtensionId
-      }
-    }).then(function (max) {
-      // SET PRIORITY
-      if (req.body.VoiceExtensionId) {
-        req.body.priority = max ? ++max : 2;
-        application = _.cloneDeep(Applications[req.body.app]);
-        if (!application || req.body.customApp) {
-          application = [{
-            app: 'GotoIfTime',
-            appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-          }, {
-            app: 'custom',
-            appdata: '%s',
-            isApp: true
-          }, {
-            app: 'NoOp',
-            appdata: 'Custom Application End'
-          }];
-        }
-        appGroup = util.format('%s%s%s', req.body.context, req.body.exten, req.body.priority);
-        // interval = createInterval(req.body);
-
-
-        req.body.interval = req.body.interval || '*,*,*,*';
-        Interval
-          .findAll({
-            where: {
-              IntervalId: (req.body.IntervalId !== null) ? req.body.IntervalId : 0
-            }
-          })
-          .then(function (Intervals) {
-            var intervals = [];
-            var gotoInterval;
-            if (Intervals && Intervals.length > 0) {
-              application.splice(0, 1);
-              intervals = _.pluck(Intervals, 'dataValues');
-              intervals.forEach(function (elem, index) {
-                // gotoInterval = createInterval(elem);
-                application.unshift({
-                  app: 'GotoIfTimeFromArray',
-                  appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                  IntervalId: elem.id,
-                  interval: gotoInterval,
-                  isInterval: true
-                });
-              })
-            }
-            appCreate(application, req.body, appGroup, intervals);
-            VoiceExtension
-              .bulkCreate(application)
-              .then(function (voiceExtensions) {
-                return res.status(201).send(voiceExtensions);
-              })
-          })
-      } else {
-        VoiceExtension
-          .findAll({
-            where: {
-              exten: req.body.exten,
-              context: req.body.context,
-              type: req.body.type,
-            }
-          })
-          .then(function (existingExtensions) {
-            //console.log(existingExtensions);
-            //console.log('Finding app row.....');
-            if (!existingExtensions) {
-              return res.sendStatus(404);
-            }
-            if (existingExtensions.length > 0) {
-              return res.status(500).send({
-                message: 'MESSAGE_EXIST_ROUTE'
-              });
-            }
-            req.body.priority = 1;
-            VoiceExtension
-              .create(req.body)
-              .then(function (voiceExtensions) {
-                return res.status(201).send(voiceExtensions);
-              })
-              .catch(function (err) {
-                return res.handleError(err);
-              })
-          })
-          .catch(function (err) {
-            return res.handleError(err);
-          });
-      }
-      // //console.log(application);
-
-    })
-    .catch(function (err) {
-      next(err);
-    });
-};
-
-// function createInterval(element) {
-//   var interval = [];
-//   if (element.t_from && element.t_from !== '') {
-//     interval[0] = element.t_from;
-//     if (element.t_to && element.t_to !== '') {
-//       interval[0] += '-' + element.t_to;
-//     }
-//   } else {
-//     interval[0] = '*';
-//   }
-//
-//   if (element.wd_from && element.wd_from !== '') {
-//     interval[1] = element.wd_from;
-//     if (element.wd_to && element.wd_to !== '') {
-//       interval[1] += '-' + element.wd_to;
-//     }
-//   } else {
-//     interval[1] = '*';
-//   }
-//
-//   if (element.md_from && element.md_from !== '') {
-//     interval[2] = element.md_from;
-//     if (element.md_to && element.md_to !== '') {
-//       interval[2] += '-' + element.md_to;
-//     }
-//   } else {
-//     interval[2] = '*';
-//   }
-//
-//   if (element.m_from && element.m_from !== '') {
-//     interval[3] = element.m_from;
-//     if (element.m_to && element.m_to !== '') {
-//       interval[3] += '-' + element.m_to;
-//     }
-//   } else {
-//     interval[3] = '*';
-//   }
-//
-//   return interval.join(',');
-// }
-
-function appCreate(application, element, appGroup, intervals, priority) {
-  var intLength = intervals.length;
-  if (element.customApp) {
-    element.app = 'custom'; //in questo modo posso rimuovere il default dello switch, ma lo lascio per completezza
-  }
-  switch (element.app) {
-  case 'Dial':
-    if (!element.callerID) {
-      _.remove(application, {
-        app: 'Set'
-      });
-    }
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'Dial':
-        if (element.type === 'outbound') {
-          elem.IntervalId = element.IntervalId;
-          elem.interval = element.interval;
-          elem.trunk = element.trunk;
-          elem.TrunkId = element.TrunkId;
-          elem.cutdigits = element.cutdigits || 0;
-          elem.callerID = element.callerID || null;
-          // elem.appdata = util.format('SIP/${EXTEN:%d}@%s', elem.cutdigits, elem.trunk);
-        } else {
-          elem.IntervalId = element.IntervalId;
-          elem.interval = element.interval;
-          elem.interface = element.interface;
-          elem.app_options = element.app_options || '';
-          elem.timeout = element.timeout || '';
-          elem.url = element.url || '';
-          elem.appdata = util.format(elem.appdata, element.interface, elem.timeout, elem.app_options ? elem.app_options.replace(',', '') : '', elem.url);
-        }
-        break;
-      case 'Set':
-        elem.appdata = util.format(elem.appdata, element.callerID);
-        break;
-      case 'NoOp':
-        if (element.type === 'outbound') {
-          elem.appdata = 'Outbound Dial Application End';
-        }
-        break;
-      default:
-
-      }
-    });
-    break;
-  case 'Queue':
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'Queue':
-        elem.IntervalId = element.IntervalId;
-        elem.app_options = element.app_options || '';
-        elem.audiofile = element.audiofile || '';
-        elem.queue = element.queue;
-        elem.interval = element.interval;
-        elem.interface = element.interface;
-        elem.app_options = element.app_options;
-        elem.timeout = element.timeout || '';
-        elem.url = element.url || '';
-        elem.appdata = util.format(elem.appdata, elem.queue, elem.app_options ? elem.app_options.replace(',', '') : '', elem.url, elem.audiofile, elem.timeout);
-        break;
-      default:
-
-      }
-    });
-    break;
-  case 'Playback':
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'Playback':
-        elem.IntervalId = element.IntervalId;
-        elem.interval = element.interval;
-        elem.audiofile = element.audiofile || '';
-        elem.app_options = element.app_options || '';
-        elem.appdata = util.format(elem.appdata, elem.audiofile, elem.app_options ? elem.app_options.replace(',', '') : '');
-        break;
-      default:
-
-      }
-    });
-    break;
-  case 'AGI':
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'AGI':
-        elem.IntervalId = element.IntervalId;
-        elem.interval = element.interval;
-        elem.project = element.project;
-        elem.appdata = util.format(elem.appdata, elem.project);
-        break;
-      default:
-
-      }
-    });
-    break;
-  case 'Goto':
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'Goto':
-        elem.IntervalId = element.IntervalId;
-        elem.interval = element.interval;
-        elem.alt_priority = element.alt_priority;
-        elem.alt_extension = element.alt_extension;
-        elem.alt_context = element.alt_context;
-        elem.appdata = util.format(elem.appdata, elem.alt_context, elem.alt_extension, elem.alt_priority);
-        break;
-      default:
-
-      }
-    });
-    break;
-  case 'Hangup':
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'Hangup':
-        elem.IntervalId = element.IntervalId;
-        elem.interval = element.interval;
-        elem.causecode = element.causecode;
-        elem.appdata = util.format(elem.appdata, elem.causecode);
-        break;
-      default:
-
-      }
-    });
-    break;
-  case 'Set':
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'Set':
-        elem.IntervalId = element.IntervalId;
-        elem.interval = element.interval;
-        elem.variable = element.variable;
-        elem.value = element.value;
-        elem.appdata = util.format(elem.appdata, elem.variable, elem.value);
-        break;
-      default:
-
-      }
-    });
-    break;
-  case 'custom':
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'custom':
-        elem.IntervalId = element.IntervalId;
-        elem.interval = element.interval;
-        elem.app = elem.customApp = element.customApp;
-        elem.appdata = util.format(elem.appdata, element.appdata);
-        break;
-      default:
-
-      }
-    });
-    break;
-  case 'Voicemail':
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'Voicemail':
-        elem.IntervalId = element.IntervalId;
-        elem.interval = element.interval;
-        elem.mailbox = element.mailbox;
-        elem.appdata = util.format(elem.appdata, elem.mailbox);
-        break;
-      default:
-
-      }
-    });
-    break;
-  default:
-    application.forEach(function (elem, index) {
-      elem.exten = element.exten;
-      elem.type = element.type;
-      elem.context = element.context;
-      elem.VoiceExtensionId = element.VoiceExtensionId;
-      elem.priority = priority ? priority++ : element.priority++;
-      elem.appGroup = appGroup;
-      switch (elem.app) {
-      case 'GotoIfTime':
-        elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-        break;
-      case 'GotoIfTimeFromArray':
-        elem.app = 'GotoIfTime';
-        elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-        break;
-      case 'custom':
-        elem.IntervalId = element.IntervalId;
-        elem.interval = element.interval;
-        elem.app = elem.customApp = element.customApp;
-        elem.appdata = util.format(elem.appdata, element.appdata);
-        break;
-      default:
-
-      }
-    });
-
-  }
-  if (priority) {
-    return priority;
-  }
-}
-
-// Updates an existing voice_extension in the DB.
-exports.update = function (req, res) {
-  VoiceExtension
-    .findAll({
-      where: {
-        exten: req.body.exten,
-        context: req.body.context,
-        type: req.body.type,
-        VoiceExtensionId: null,
-        id: {
-          $ne: req.body.id
-        }
-      }
-    })
-    .then(function (existingExtensions) {
-      //console.log(existingExtensions);
-      //console.log('Finding app row.....');
-      if (!existingExtensions) {
-        return res.sendStatus(404);
-      }
-      if (existingExtensions.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_ROUTE'
-        })
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      VoiceExtension
-        .find({
-          where: {
-            id: req.params.id
-          }
-        })
-        .then(function (voice_extension) {
-          if (!voice_extension) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(voice_extension, req.body);
-          return sequelize.transaction(function (t) {
-              return updated.save({
-                  transaction: t
-                })
-                .then(function (updatedRoute) {
-                  VoiceExtension
-                    .findAll({
-                      where: {
-                        VoiceExtensionId: updatedRoute.id,
-                        isApp: true
-                      }
-                    })
-                    .then(function (voiceExtensions) {
-                      return VoiceExtension.destroy({
-                          where: {
-                            VoiceExtensionId: updatedRoute.id
-                          }
-                        }, {
-                          transaction: t
-                        })
-                        .then(function () {
-                          voiceExtensions = _.pluck(voiceExtensions, 'dataValues');
-                          var intervalIds = _.filter(_.pluck(voiceExtensions, 'IntervalId'), function (elem) {
-                            return elem !== null;
-                          });
-                          Interval
-                            .findAll({
-                              where: {
-                                IntervalId: intervalIds
-                              }
-                            })
-                            .then(function (intervals) {
-                              var priority = 2;
-                              var interval;
-                              voiceExtensions.forEach(function (tmpElem) {
-                                var application = _.cloneDeep(Applications[tmpElem.app]);
-                                if (!application || tmpElem.customApp) {
-                                  application = [{
-                                    app: 'GotoIfTime',
-                                    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                                  }, {
-                                    app: 'custom',
-                                    appdata: '%s',
-                                    isApp: true
-                                  }, {
-                                    app: 'NoOp',
-                                    appdata: 'Custom Application End'
-                                  }];
-                                }
-                                tmpElem.context = updatedRoute.context;
-                                tmpElem.exten = updatedRoute.exten;
-                                var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority);
-                                tmpElem.interval = tmpElem.interval || '*,*,*,*';
-                                var tmpIntervals = _.filter(intervals, function (elem) {
-                                  return (elem.IntervalId == tmpElem.IntervalId);
-                                });
-                                if (tmpIntervals && tmpIntervals.length > 0) {
-                                  application.splice(0, 1);
-                                  tmpIntervals.forEach(function (elem, index) {
-                                    application.unshift({
-                                      app: 'GotoIfTimeFromArray',
-                                      appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                                      IntervalId: elem.id,
-                                      isInterval: true,
-                                      interval: elem.interval
-                                    });
-                                  })
-                                }
-                                priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority);
-                                VoiceExtension
-                                  .bulkCreate(application)
-                              });
-                              return res.sendStatus(200);
-                            })
-                        })
-                    })
-                })
-            })
-            .catch(function (err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing voice_extension in the DB.
-exports.updateApplication = function (req, res, next) {
-  var interval;
-  if (req.body.appdata) {
-    delete req.body.appdata;
-  }
-
-  //console.log('Finding app row.....');
-  VoiceExtension
-    .findById(req.body.id)
-    .then(function (voiceExtension) {
-      if (!voiceExtension) {
-        return res.sendStatus(404);
-      }
-      delete req.body.id;
-      var updated = _.merge(voiceExtension, req.body);
-      //console.log('Updating app row.....');
-      return sequelize.transaction(function (t) {
-          return updated.save({
-              transaction: t
-            })
-            .then(function () {
-              //console.log('Finding extension apps..');
-              VoiceExtension
-                .findAll({
-                  where: {
-                    VoiceExtensionId: req.body.VoiceExtensionId,
-                    isApp: true
-                  }
-                })
-                .then(function (voiceExtensions) {
-                  //console.log('Extensions found');
-                  //console.log('Destroying extension rows...');
-                  return VoiceExtension.destroy({
-                      where: {
-                        VoiceExtensionId: req.body.VoiceExtensionId
-                      }
-                    }, {
-                      transaction: t
-                    })
-                    .then(function () {
-                      voiceExtensions = _.pluck(voiceExtensions, 'dataValues');
-                      var intervalIds = _.filter(_.pluck(voiceExtensions, 'IntervalId'), function (elem) {
-                        return elem !== null;
-                      });
-                      return Interval
-                        .findAll({
-                          where: {
-                            IntervalId: intervalIds
-                          }
-                        })
-                        .then(function (intervals) {
-                          //console.log('Creating extension rows...');
-                          var priority = 2;
-                          var interval;
-                          voiceExtensions.forEach(function (tmpElem) {
-                            //console.log('Creating app..');
-                            var application = _.cloneDeep(Applications[tmpElem.app]);
-                            if (!application || tmpElem.customApp) {
-                              application = [{
-                                app: 'GotoIfTime',
-                                appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                              }, {
-                                app: 'custom',
-                                appdata: '%s',
-                                isApp: true
-                              }, {
-                                app: 'NoOp',
-                                appdata: 'Custom Application End'
-                              }];
-                            }
-                            //console.log('PRIORITY');
-                            //console.log(priority);
-                            var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority);
-                            tmpElem.interval = tmpElem.interval || '*,*,*,*';
-                            var tmpIntervals = _.filter(intervals, function (elem) {
-                              return (elem.IntervalId == tmpElem.IntervalId);
-                            });
-                            if (tmpIntervals && tmpIntervals.length > 0) {
-                              application.splice(0, 1);
-                              tmpIntervals.forEach(function (elem, index) {
-                                // interval = createInterval(elem);
-                                application.unshift({
-                                  app: 'GotoIfTimeFromArray',
-                                  appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                                  IntervalId: elem.id,
-                                  isInterval: true,
-                                  interval: elem.interval
-                                });
-                              })
-                            }
-                            priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority);
-                            //console.log('returned priority');
-                            //console.log(priority);
-                            VoiceExtension
-                              .bulkCreate(application)
-                          });
-                          //console.log('THE END');
-                        })
-                    })
-                })
-            })
-        })
-        .then(function (result) {
-          return res.status(201).send(result);
-        })
-        .catch(function (err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-
-};
-
-// Deletes a voice_extension from the DB.
-exports.destroy = function (req, res, next) {
-  VoiceExtension
-    .findById(req.params.id)
-    .then(function (voice_extension) {
-      if (!voice_extension) {
-        return res.sendStatus(404);
-      }
-      if (!voice_extension.VoiceExtensionId) {
-        voice_extension.destroy()
-          .then(function () {
-            return res.sendStatus(204);
-          })
-          .catch(function (err) {
-            return handleError(res, err);
-          });
-      } else {
-        //console.log('isApplication');
-        VoiceExtension
-          .findAll({
-            where: {
-              appGroup: voice_extension.appGroup
-            }
-          })
-          .then(function (voice_extensions) {
-            //console.log('found extensions');
-            if (!voice_extensions) {
-              return res.sendStatus(404);
-            }
-            return sequelize.transaction(function (t) {
-                //console.log('trying to delete');
-                return VoiceExtension.destroy({
-                    where: {
-                      appGroup: voice_extension.appGroup
-                    }
-                  }, {
-                    transaction: t
-                  })
-                  .then(function (deleted_rows) {
-                    //console.log('the length of the group is', deleted_rows);
-                    // //console.log(voice_extensions);
-                    return VoiceExtension
-                      .findAll({
-                        where: {
-                          VoiceExtensionId: voice_extension.VoiceExtensionId,
-                          priority: {
-                            $gt: voice_extensions[deleted_rows - 1].priority
-                          }
-                        }
-                      })
-                      .then(function (voiceApplications) {
-                        return VoiceExtension
-                          .destroy({
-                            where: {
-                              VoiceExtensionId: voice_extension.VoiceExtensionId,
-                              priority: {
-                                $gt: voice_extensions[deleted_rows - 1].priority
-                              }
-                            }
-                          }, {
-                            transaction: t
-                          })
-                          .then(function () {
-                            var appGroups = _.pluck(_.filter(_.pluck(voiceApplications, 'dataValues'), function (elem) {
-                              return elem.isApp === true;
-                            }), 'appGroup');
-                            var priority = voice_extensions[0].priority;
-                            appGroups.forEach(function (sortedElem) {
-                              var tmpElem = _.find(voiceApplications, function (elem) {
-                                return (elem.appGroup == sortedElem && elem.isApp === true);
-                              });
-                              var application = _.cloneDeep(Applications[tmpElem.app]);
-                              if (!application || tmpElem.customApp) {
-                                application = [{
-                                  app: 'GotoIfTime',
-                                  appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                                }, {
-                                  app: 'custom',
-                                  appdata: '%s',
-                                  isApp: true
-                                }, {
-                                  app: 'NoOp',
-                                  appdata: 'Custom Application End'
-                                }];
-                              }
-                              //console.log('PRIORITY');
-                              //console.log(priority);
-                              var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority);
-                              tmpElem.interval = tmpElem.interval || '*,*,*,*';
-                              var tmpIntervals = _.filter(voiceApplications, function (elem) {
-                                return (elem.appGroup == sortedElem && elem.isInterval === true);
-                              });
-                              if (tmpIntervals && tmpIntervals.length > 0) {
-                                application.splice(0, 1);
-                                tmpIntervals.forEach(function (elem, index) {
-
-                                  application.unshift({
-                                    app: 'GotoIfTimeFromArray',
-                                    appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                                    IntervalId: elem.IntervalId ? elem.IntervalId : null,
-                                    isInterval: true,
-                                    interval: elem.interval,
-                                  });
-                                })
-                              }
-                              priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority);
-                              //console.log('returned priority');
-                              //console.log(priority);
-                              VoiceExtension
-                                .bulkCreate(application)
-                            });
-                          })
-                      })
-                  })
-              })
-              .then(function (result) {
-                // VoiceExtension
-                //   .findAll({
-                //     where: {
-                //       VoiceExtensionId: voice_extension.VoiceExtensionId,
-                //       isApp: true
-                //     }
-                //   })
-                //   .then(function(voiceExtensions) {
-                //     // //console.log(_.pluck(voiceExtensions, 'dataValues'));
-                //     return res.status(201).send(voiceExtensions);
-                //   })
-                res.sendStatus(201);
-              })
-              .catch(function (err) {
-                return next(err);
-              });
-          })
-      }
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-
-// Deletes a agent from the DB.
-exports.bulkDestroy = function (req, res) {
-  VoiceExtension
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function () {
-      return res.sendStatus(204);
-    })
-    .catch(function (err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/voice_extension/voice_extension.socket.js b/server/api/voice_extension/voice_extension.socket.js
index da477d1..3ab3b4b 100644
--- a/server/api/voice_extension/voice_extension.socket.js
+++ b/server/api/voice_extension/voice_extension.socket.js
@@ -1,34 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var VoiceExtension = require('../../models').VoiceExtension;
-
-exports.register = function(socket) {
-  VoiceExtension.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  VoiceExtension.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-  VoiceExtension.afterBulkDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-  VoiceExtension.afterUpdate(function(doc) {
-    onUpdate(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('voice_extension:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('voice_extension:remove', doc);
-}
-
-function onUpdate(socket, doc, cb) {
-  socket.emit('voice_extension:update', doc);
-}
\ No newline at end of file
diff --git a/server/api/voice_extension/voice_extension.spec.js b/server/api/voice_extension/voice_extension.spec.js
index 0971536..d57323f 100644
--- a/server/api/voice_extension/voice_extension.spec.js
+++ b/server/api/voice_extension/voice_extension.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/voice/extensions', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/voice/extensions')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/voice_musiconhold/index.js b/server/api/voice_musiconhold/index.js
index 59cc818..b292740 100644
--- a/server/api/voice_musiconhold/index.js
+++ b/server/api/voice_musiconhold/index.js
@@ -1,21 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./voice_musiconhold.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/stream', auth.isAuthenticated(), controller.stream);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id/files', auth.isAuthenticated(), controller.showAudioFiles);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.mohValidation);
-router.post('/:id/files', auth.isAuthenticated(), controller.addFiles);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-router.delete('/:id/files', auth.isAuthenticated(), controller.deleteAudioFiles);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/voice_musiconhold/voice_musiconhold.controller.js b/server/api/voice_musiconhold/voice_musiconhold.controller.js
index 72f8b70..f453bb9 100644
--- a/server/api/voice_musiconhold/voice_musiconhold.controller.js
+++ b/server/api/voice_musiconhold/voice_musiconhold.controller.js
@@ -1,357 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var VoiceMusicOnHold = require('../../models').VoiceMusicOnHold;
-var fs = require('fs');
-var remove = require('remove');
-var Upload = require('../../models').Upload;
-var fse = require('fs-extra');
-var path = require('path');
-var config = require('../../config/environment');
-var sequelize = require('../../models').sequelize;
-var util = require('util');
-var base64 = require('file-base64');
-
-// Get list of voice_musiconholds
-exports.index = function(req, res) {
-
-  var attributes = ['name', 'directory', 'sort', 'description'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-
-  VoiceMusicOnHold
-    .findAndCountAll(query)
-    .then(function(result) {
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single voice_musiconhold
-exports.show = function(req, res) {
-  VoiceMusicOnHold
-    .findById(req.params.id)
-    .then(function(voice_musiconhold) {
-      if (!voice_musiconhold) {
-        return res.sendStatus(404);
-      }
-      return res.send(voice_musiconhold);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Add files to moh class
-exports.addFiles = function(req, res) {
-  VoiceMusicOnHold
-    .findById(req.params.id)
-    .then(function(voice_musiconhold) {
-      if (!voice_musiconhold) {
-        return res.sendStatus(404);
-      }
-      Upload
-        .findAll({
-          where: {
-            id: req.body.sounds
-          }
-        })
-        .then(function(soundFiles) {
-          var origin = path.join(config.root, 'server/files/sounds/converted');
-          var dest;
-          soundFiles.forEach(function(elem) {
-            dest = path.join(voice_musiconhold.directory, elem.display_name + '.wav');
-            fse.copySync(path.join(origin, elem.save_name + '.wav'), dest);
-          });
-          fs.chmodSync(dest, parseInt('0777', 8));
-          res.sendStatus(200);
-        })
-        .catch(function(err) {
-          console.log(err);
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.showAudioFiles = function(req, res) {
-  var fileObject = {};
-  VoiceMusicOnHold
-    .findById(req.params.id)
-    .then(function(voice_musiconhold) {
-      if (!voice_musiconhold) {
-        return res.sendStatus(404);
-      }
-      fileObject.path = voice_musiconhold.directory;
-      fs.readdir(voice_musiconhold.directory, function(err, files) {
-        if (!err) {
-          fileObject.files = files;
-          return res.send(fileObject);
-        } else {
-          throw err;
-        }
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.deleteAudioFiles = function(req, res) {
-  VoiceMusicOnHold
-    .findById(req.params.id)
-    .then(function(voice_musiconhold) {
-      if (!voice_musiconhold) {
-        return res.sendStatus(404);
-      }
-      var deletePath = voice_musiconhold.directory + '/' + req.query.filename;
-      fs.unlink(deletePath, function(err) {
-        if (err) {
-          return handleError(res, err);
-        } else {
-          return res.sendStatus(204);
-        }
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Validate the existence of a route
-exports.mohValidation = function(req, res) {
-  console.log(req.body);
-  VoiceMusicOnHold
-    .findAll({
-      where: {
-        name: req.body.name,
-      }
-    })
-    .then(function(voice_mohs) {
-      if (!voice_mohs) {
-        return res.sendStatus(404);
-      }
-      return res.send(voice_mohs);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new voice_musiconhold in the DB.
-exports.create = function(req, res) {
-  VoiceMusicOnHold
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(existingMohs) {
-      console.log(existingMohs);
-      console.log('Finding app row.....');
-      if (!existingMohs) {
-        console.log('error1');
-        return res.sendStatus(404);
-      }
-      if (existingMohs.length > 0) {
-        console.log('error2');
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_MOH'
-        });
-      }
-      return sequelize.transaction().then(function(t) {
-        req.body.directory = path.join(config.root, 'server/files/moh', req.body.name);
-        return VoiceMusicOnHold
-          .create(req.body, {
-            transaction: t
-          })
-          .then(function(voice_musiconhold) {
-            fs.mkdir(voice_musiconhold.directory, parseInt('0777', 8), function(err) {
-              if (err) {
-                console.log('file error');
-                t.rollback();
-                return res.status(500).send({
-                  message: 'MESSAGE_FILE_CREATION_ERROR'
-                });
-              }
-              t.commit();
-              console.log('file created');
-              return res.status(201).send(voice_musiconhold);
-            });
-          })
-          .catch(function(err) {
-            t.rollback();
-          });
-      })
-    })
-    .catch(function(err) {
-      console.log('thaterror');
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing voice_musiconhold in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  VoiceMusicOnHold
-    .find({
-      where: {
-        id: req.params.id
-      }
-    })
-    .then(function(voice_musiconhold) {
-      if (!voice_musiconhold) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(voice_musiconhold, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(voice_musiconhold);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a voice_musiconhold from the DB.
-exports.destroy = function(req, res) {
-  VoiceMusicOnHold
-    .findById(req.params.id)
-    .then(function(voice_musiconhold) {
-      if (!voice_musiconhold) {
-        return res.sendStatus(404);
-      }
-      return sequelize.transaction(function(t) {
-          return voice_musiconhold.destroy({
-              transaction: t
-            })
-            .then(function() {
-              remove(voice_musiconhold.directory, function(err) {
-                if (err) {
-                  console.log(err);
-                }
-                return res.sendStatus(204);
-              });
-            })
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes multiple voice_musiconholds from the DB.
-exports.bulkDestroy = function(req, res) {
-  VoiceMusicOnHold
-    .findAll({
-      where: {
-        id: req.query.id
-      }
-    })
-    .then(function(voice_musiconholds) {
-      if (!voice_musiconholds) {
-        return res.sendStatus(404);
-      }
-      return sequelize.transaction(function(t) {
-          voice_musiconholds.forEach(function(element) {
-            return element.destroy({
-                transaction: t
-              })
-              .then(function() {
-                remove(element.directory, function(err) {
-                  if (err) {
-                    console.log(err);
-                    throw err
-                  }
-                });
-              })
-          })
-        })
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          console.log(err);
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// stream a moh file
-exports.stream = function(req, res) {
-  var filepath = decodeURI(req.query.path);
-  base64.encode(filepath, function(err, base64String) {
-    if (err) {
-      return handleError(res, err);
-    } else {
-      return res.status(200).send(base64String);
-    }
-  });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/voice_musiconhold/voice_musiconhold.socket.js b/server/api/voice_musiconhold/voice_musiconhold.socket.js
index efa073f..dcb9080 100644
--- a/server/api/voice_musiconhold/voice_musiconhold.socket.js
+++ b/server/api/voice_musiconhold/voice_musiconhold.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var VoiceMusicOnHold = require('../../models').VoiceMusicOnHold;
-
-exports.register = function(socket) {
-  VoiceMusicOnHold.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  VoiceMusicOnHold.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('voice_musiconhold:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('voice_musiconhold:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/voice_musiconhold/voice_musiconhold.spec.js b/server/api/voice_musiconhold/voice_musiconhold.spec.js
index e992daf..06cd99b 100644
--- a/server/api/voice_musiconhold/voice_musiconhold.spec.js
+++ b/server/api/voice_musiconhold/voice_musiconhold.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/voice/musiconhold', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/voice/musiconhold')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/voice_queue/index.js b/server/api/voice_queue/index.js
index a11cd5b..5027fd0 100644
--- a/server/api/voice_queue/index.js
+++ b/server/api/voice_queue/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./voice_queue.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.queueValidation);
-router.post('/:id/agents', auth.isAuthenticated(), controller.addAgents);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.put('/:id/agents', auth.isAuthenticated(), controller.removeAgents);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:name', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/voice_queue/voice_queue.controller.js b/server/api/voice_queue/voice_queue.controller.js
index 209bdeb..9051570 100644
--- a/server/api/voice_queue/voice_queue.controller.js
+++ b/server/api/voice_queue/voice_queue.controller.js
@@ -1,339 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var User = require('../../models').User;
-var VoiceQueue = require('../../models').VoiceQueue;
-var UserHasVoiceQueue = require('../../models').UserHasVoiceQueue;
-var VoiceExtension = require('../../models').VoiceExtension;
-
-// Get list of voice_queues
-exports.index = function(req, res) {
-  // console.log(req.query.page);
-  var attributes = ['name', 'description', 'strategy', 'context'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  VoiceQueue
-    .findAndCountAll(query)
-    .then(function(result) {
-      console.log(result.count);
-      var total_pages = Math.ceil(result.count / per_page);
-      console.log(total_pages);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single voice_queue
-exports.show = function(req, res) {
-  VoiceQueue
-    .findById(req.params.id)
-    .then(function(voice_queue) {
-      if (!voice_queue) {
-        return res.sendStatus(404);
-      }
-      return res.send(voice_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Validate the existence of a queue
-exports.queueValidation = function(req, res) {
-  console.log(req.body);
-  VoiceQueue
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(voice_queue) {
-      if (!voice_queue) {
-        return res.sendStatus(404);
-      }
-      return res.send(voice_queue);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new voice_queue in the DB.
-exports.create = function(req, res) {
-  VoiceQueue
-    .findAll({
-      where: {
-        name: req.body.name
-      }
-    })
-    .then(function(existingQueues) {
-      console.log(existingQueues);
-      console.log('Finding app row.....');
-      if (!existingQueues) {
-        return res.sendStatus(404);
-      }
-      if (existingQueues.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_QUEUE'
-        });
-      }
-      VoiceQueue
-        .create(req.body)
-        .then(function(voice_queue) {
-          return res.status(201).send(voice_queue);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing voice_queue in the DB.
-exports.update = function(req, res) {
-  VoiceQueue
-    .find({
-      where: {
-        name: req.params.id
-      }
-    })
-    .then(function(voiceQueue) {
-      if (!voiceQueue) {
-        return res.sendStatus(404);
-      }
-      if (req.body.id) {
-        delete req.body.id;
-      }
-      var updated = _.merge(voiceQueue, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(voiceQueue);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-
-// Updates an existing user_has_voiceQueue in the DB.
-exports.addAgents = function(req, res, next) {
-
-  console.log('addAgents');
-  console.log(req.params);
-  console.log(req.body);
-  User
-    .findAll({
-      where: {
-        id: {
-          $in: req.body.agents
-        }
-      }
-    })
-    .then(function(users) {
-      // console.log(users);
-      var userHasVoiceQueues = _.map(users, function(user) {
-        return {
-          queue: req.params.id,
-          location: util.format('SIP/%s', user.name),
-          membername: user.name,
-          VoiceQueueName: req.params.id,
-          UserId: user.id
-        };
-      });
-
-      UserHasVoiceQueue
-        .bulkCreate(userHasVoiceQueues, {
-          individualHooks: true
-        })
-        .then(function() {
-          return res.sendStatus(200);
-        })
-        .catch(function(err) {
-          return next(err);
-        });
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-exports.removeAgents = function(req, res, next) {
-  VoiceQueue
-    .find({
-      where: {
-        name: req.params.id
-      }
-    })
-    .then(function(voiceQueue) {
-      if (voiceQueue) {
-        // QUEUE FOUND
-        // REMOVE AGENTS
-        voiceQueue
-          .removeUsers(req.body.agents, {
-            individualHooks: true
-          })
-          .then(function() {
-            return res.sendStatus(200);
-          })
-          .catch(function(err) {
-            return next(err);
-          });
-      } else {
-        return next(new Error('no mail queue found'));
-      }
-    })
-    .catch(function(err) {
-      return next(err);
-    });
-};
-
-// Deletes a voice_queue from the DB.
-exports.destroy = function(req, res) {
-  VoiceQueue
-    .find({
-      where: {
-        name: req.params.name
-      }
-    })
-    .then(function(voice_queue) {
-      if (!voice_queue) {
-        return res.sendStatus(404);
-      }
-      VoiceExtension
-        .findAll({
-          where: {
-            queue: voice_queue.name
-          }
-        })
-        .then(function(contextExtensions) {
-          if (contextExtensions.length > 0) {
-            return res.status(500).send({
-              message: 'MESSAGE_QUEUE_ROUTE_ASSOCIATED'
-            });
-          }
-          voice_queue.destroy()
-            .then(function() {
-              return res.sendStatus(204);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes multiple voice_queues from the DB.
-exports.bulkDestroy = function(req, res) {
-  VoiceQueue
-    .findAll({
-      where: {
-        name: req.query.name
-      }
-    })
-    .then(function(voice_queues) {
-      if (!voice_queues) {
-        return res.sendStatus(404);
-      }
-      var destroyQueuesNames = _.pluck(_.pluck(voice_queues, 'dataValues'), 'name');
-      console.log(destroyQueuesNames);
-      VoiceExtension
-        .findAll({
-          where: {
-            queue: destroyQueuesNames
-          }
-        })
-        .then(function(contextExtensions) {
-          if (contextExtensions.length > 0) {
-            return res.status(500).send({
-              message: 'MESSAGE_QUEUE_ROUTE_ASSOCIATED'
-            });
-          }
-          VoiceQueue
-            .destroy({
-              where: {
-                name: req.query.name
-              },
-              individualHooks: true
-            })
-            .then(function() {
-              return res.sendStatus(204);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/voice_queue/voice_queue.socket.js b/server/api/voice_queue/voice_queue.socket.js
index 6cb2204..361c0fb 100644
--- a/server/api/voice_queue/voice_queue.socket.js
+++ b/server/api/voice_queue/voice_queue.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var VoiceQueue = require('../../models').VoiceQueue;
-
-exports.register = function(socket) {
-  VoiceQueue.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  VoiceQueue.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('voice_queue:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('voice_queue:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/voice_queue/voice_queue.spec.js b/server/api/voice_queue/voice_queue.spec.js
index fd49ebd..9b456f4 100644
--- a/server/api/voice_queue/voice_queue.spec.js
+++ b/server/api/voice_queue/voice_queue.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/voice/queues', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/voice/queues')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/voice_voicemail/index.js b/server/api/voice_voicemail/index.js
index 04c5ac8..ad0cf73 100644
--- a/server/api/voice_voicemail/index.js
+++ b/server/api/voice_voicemail/index.js
@@ -1,21 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./voice_voicemail.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:uniqueid', auth.isAuthenticated(), controller.show);
-router.get('/:uniqueid/messages', auth.isAuthenticated(), controller.getMessages);
-router.get('/messages/:id/download', auth.isAuthenticated(), controller.downloadMessage);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.post('/validate', auth.isAuthenticated(), controller.mailboxValidation);
-router.put('/:uniqueid', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:uniqueid', auth.isAuthenticated(), controller.destroy);
-router.delete('/messages/:id/delete', auth.isAuthenticated(), controller.destroyMessage);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/voice_voicemail/voice_voicemail.controller.js b/server/api/voice_voicemail/voice_voicemail.controller.js
index eed06af..4f4556e 100644
--- a/server/api/voice_voicemail/voice_voicemail.controller.js
+++ b/server/api/voice_voicemail/voice_voicemail.controller.js
@@ -1,298 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var VoiceVoicemail = require('../../models').VoiceVoicemail;
-var VoiceVoicemailMessages = require('../../models').VoiceVoicemailMessages;
-var stream = require('stream');
-
-// Get list of voice_voicemails
-exports.index = function(req, res) {
-
-  var attributes = ['mailbox', 'fullname', 'email'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-
-  VoiceVoicemail
-    .findAndCountAll(query)
-    .then(function(voice_voicemails) {
-      return res.status(200).send(voice_voicemails);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single voice_voicemail
-exports.show = function(req, res) {
-  VoiceVoicemail
-    .find({
-      where: {
-        uniqueid: req.params.uniqueid
-      }
-    })
-    .then(function(voice_voicemail) {
-      if (!voice_voicemail) {
-        return res.sendStatus(404);
-      }
-      return res.send(voice_voicemail);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.getMessages = function(req, res) {
-  VoiceVoicemail
-    .find({
-      where: {
-        uniqueid: req.params.uniqueid
-      }
-    })
-    .then(function(voice_voicemail) {
-      VoiceVoicemailMessages
-        .findAll({
-          where: {
-            mailboxcontext: voice_voicemail.context,
-            mailboxuser: voice_voicemail.mailbox
-          }
-        })
-        .then(function(voicemailMessages) {
-          return res.status(200).send(voicemailMessages);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// validate mailbox uniqueness
-exports.mailboxValidation = function(req, res) {
-  console.log(req.body);
-  VoiceVoicemail
-    .findAll({
-      where: {
-        mailbox: req.body.mailbox,
-        context: req.body.context
-      }
-    })
-    .then(function(voicemails) {
-      if (!voicemails) {
-        return res.sendStatus(404);
-      }
-      return res.send(voicemails);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-// Creates a new voice_voicemail in the DB.
-exports.create = function(req, res) {
-  VoiceVoicemail
-    .findAll({
-      where: {
-        mailbox: req.body.mailbox,
-        context: req.body.context
-      }
-    })
-    .then(function(voicemails) {
-      if (!voicemails) {
-        return res.sendStatus(404);
-      }
-      if (voicemails.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_MAILBOX'
-        })
-      }
-      VoiceVoicemail
-        .create(req.body)
-        .then(function(voice_voicemail) {
-          return res.status(201).send(voice_voicemail);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-};
-
-// Updates an existing voice_voicemail in the DB.
-exports.update = function(req, res) {
-  VoiceVoicemail
-    .findAll({
-      where: {
-        mailbox: req.body.mailbox,
-        context: req.body.context,
-        uniqueid: {
-          $ne: req.body.uniqueid
-        }
-      }
-    })
-    .then(function(voicemails) {
-      if (!voicemails) {
-        return res.sendStatus(404);
-      }
-      if (voicemails.length > 0) {
-        return res.status(500).send({
-          message: 'MESSAGE_EXIST_MAILBOX'
-        })
-      }
-      if (req.body.uniqueid) {
-        delete req.body.uniqueid;
-      }
-      VoiceVoicemail
-        .find({
-          where: {
-            uniqueid: req.params.uniqueid
-          }
-        })
-        .then(function(voice_voicemail) {
-          if (!voice_voicemail) {
-            return res.sendStatus(404);
-          }
-          var updated = _.merge(voice_voicemail, req.body);
-          updated.save()
-            .then(function() {
-              return res.status(200).send(voice_voicemail);
-            })
-            .catch(function(err) {
-              return handleError(res, err);
-            });
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-
-};
-
-// Deletes a voice_voicemail from the DB.
-exports.destroy = function(req, res) {
-  VoiceVoicemail
-    .find({
-      where: {
-        uniqueid: req.params.uniqueid
-      }
-    })
-    .then(function(voice_voicemail) {
-      if (!voice_voicemail) {
-        return res.sendStatus(404);
-      }
-      voice_voicemail.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a voice_voicemail from the DB.
-exports.bulkDestroy = function(req, res) {
-  VoiceVoicemail
-    .destroy({
-      where: {
-        uniqueid: req.query.uniqueid
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a voice_voicemail message from the DB.
-exports.destroyMessage = function(req, res) {
-  VoiceVoicemailMessages
-    .findById(req.params.id)
-    .then(function(voicemailMessage) {
-      if (!voicemailMessage) {
-        return res.sendStatus(404);
-      }
-      voicemailMessage.recording = null;
-      voicemailMessage.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.downloadMessage = function(req, res) {
-  VoiceVoicemailMessages
-    .findById(req.params.id)
-    .then(function(message) {
-      if (!message) {
-        return res.sendStatus(404);
-      }
-      var filename = message.msg_id + '.wav';
-      res.writeHead(200, "OK", {
-        "Content-Type": "audio/wav",
-        "Content-Disposition": "attachment; filename=" + filename,
-        "Content-Length": message.recording.length
-      });
-      var bufferStream = new stream.PassThrough();
-      bufferStream.end(new Buffer(message.recording));
-      bufferStream.pipe(res)
-    })
-};
-
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/voice_voicemail/voice_voicemail.socket.js b/server/api/voice_voicemail/voice_voicemail.socket.js
index 41e7a38..9785ed1 100644
--- a/server/api/voice_voicemail/voice_voicemail.socket.js
+++ b/server/api/voice_voicemail/voice_voicemail.socket.js
@@ -1,39 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var VoiceVoicemail = require('../../models').VoiceVoicemail;
-var VoiceVoicemailMessages = require('../../models').VoiceVoicemailMessages;
-
-exports.register = function(socket) {
-  VoiceVoicemail.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  VoiceVoicemail.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-  VoiceVoicemailMessages.afterCreate(function(doc) {
-    onMessageSave(socket, doc);
-  });
-  VoiceVoicemailMessages.afterDestroy(function(doc) {
-    onMessageRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('voice_voicemail:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('voice_voicemail:remove', doc);
-}
-
-function onMessageSave(socket, doc, cb) {
-  socket.emit('voice_voicemail_messages:save', doc);
-}
-
-function onMessageRemove(socket, doc, cb) {
-  socket.emit('voice_voicemail_messages:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/voice_voicemail/voice_voicemail.spec.js b/server/api/voice_voicemail/voice_voicemail.spec.js
index 5785825..b59ba3c 100644
--- a/server/api/voice_voicemail/voice_voicemail.spec.js
+++ b/server/api/voice_voicemail/voice_voicemail.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/voice/voicemails', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/voice/voicemails')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/widget/index.js b/server/api/widget/index.js
index 374e711..5d0eb59 100644
--- a/server/api/widget/index.js
+++ b/server/api/widget/index.js
@@ -1,19 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./widget.controller');
-var auth = require('../../auth/auth.service');
-
-var router = express.Router();
-
-// router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/counter', auth.isAuthenticated(), controller.counter);
-router.get('/table', auth.isAuthenticated(), controller.table);
-router.get('/piechart', auth.isAuthenticated(), controller.piechart);
-// router.get('/:id', auth.isAuthenticated(), controller.show);
-// router.post('/', auth.isAuthenticated(), controller.create);
-// router.put('/:id', auth.isAuthenticated(), controller.update);
-// router.patch('/:id', auth.isAuthenticated(), controller.update);
-// router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/widget/widget.controller.js b/server/api/widget/widget.controller.js
index f9bc793..d2930bf 100644
--- a/server/api/widget/widget.controller.js
+++ b/server/api/widget/widget.controller.js
@@ -1,181 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var sequelize = require('../../models').sequelize;
-
-// var ReportAgent = require('../../models').ReportAgent;
-// var ReportCall = require('../../models').ReportCall;
-// var ReportDial = require('../../models').ReportDial;
-// var ReportMember = require('../../models').ReportMember;
-// var ReportQueue = require('../../models').ReportQueue;
-
-
-
-exports.counter = function(req, res) {
-  var table = util.format('report_%s', req.query.table);
-  sequelize.query(util.format("SELECT COUNT(*) as count FROM %s WHERE %s", table, decodeURIComponent(req.query.condition)), {
-      type: sequelize.QueryTypes.SELECT
-    })
-    .then(function(result) {
-      return res.status(200).send(result);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.table = function(req, res) {
-  var columns = [];
-  var elem;
-  if (req.query.fields) {
-    if (_.isArray(req.query.fields)) {
-      req.query.fields.forEach(function(element) {
-        elem = JSON.parse(element);
-        if (elem.column && elem.alias) {
-          columns.push(elem.column + ' AS "' + elem.alias + '"');
-        }
-      });
-    } else if (_.isString(req.query.fields)) {
-      elem = JSON.parse(req.query.fields);
-      if (elem.column && elem.alias) {
-        columns.push(elem.column + ' AS "' + elem.alias + '"');
-      }
-    }
-  }
-  var select = columns.length ? columns.join(',') : '*';
-  var table = util.format('report_%s', req.query.table);
-  sequelize.query(util.format("SELECT %s FROM %s WHERE %s", select, table, decodeURIComponent(req.query.condition)), {
-      type: sequelize.QueryTypes.SELECT
-    })
-    .then(function(result) {
-      return res.status(200).send(result);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.piechart = function(req, res) {
-  var columns = [];
-  var elem;
-  if (req.query.fields) {
-    if (_.isArray(req.query.fields)) {
-      req.query.fields.forEach(function(element) {
-        elem = JSON.parse(element);
-        if (elem.column && elem.alias) {
-          columns.push(elem.column + ' AS "' + elem.alias + '"');
-        }
-      });
-    } else if (_.isString(req.query.fields)) {
-      elem = JSON.parse(req.query.fields);
-      if (elem.column && elem.alias) {
-        columns.push(elem.column + ' AS "' + elem.alias + '"');
-      }
-    }
-  }
-  var select = columns.length ? columns.join(',') : '*';
-  var table = util.format('report_%s', req.query.table);
-  var where = '';
-  if (req.query.condition !== 'undefined') {
-    where = util.format(' WHERE %s', decodeURIComponent(req.query.condition));
-  }
-  sequelize.query(util.format("SELECT %s FROM %s%s", select, table, where), {
-      type: sequelize.QueryTypes.SELECT
-    })
-    .then(function(result) {
-      return res.status(200).send(result);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// // Get list of widgets
-// exports.index = function(req, res) {
-//   Widget
-//   .findAll()
-//   .then(function (widgets) {
-//     return res.status(200).send(widgets);
-//   })
-//   .catch(function(err) {
-//     return handleError(res, err);
-//   });
-// };
-//
-// // Get a single widget
-// exports.show = function(req, res) {
-//   Widget
-//   .findById(req.params.id)
-//   .then(function (widget) {
-//     if(!widget) { return res.sendStatus(404); }
-//     return res.send(widget);
-//   })
-//   .catch(function(err){
-//     return handleError(res, err);
-//   });
-// };
-//
-// // Creates a new widget in the DB.
-// exports.create = function(req, res) {
-//   Widget
-//   .create(req.body)
-//   .then(function(widget) {
-//     return res.status(201).send(widget);
-//   })
-//   .catch(function(err) {
-//     return handleError(res, err);
-//   });
-// };
-//
-// // Updates an existing widget in the DB.
-// exports.update = function(req, res) {
-//   if(req.body.id) { delete req.body.id; }
-//   Widget
-//   .find({
-//     where: {
-//       id: req.params.id
-//     }
-//   })
-//   .then(function (widget) {
-//     if(!widget) { return res.sendStatus(404); }
-//     var updated = _.merge(widget, req.body);
-//     updated.save()
-//     .then(function () {
-//       return res.status(200).send(widget);
-//     })
-//     .catch(function(err) {
-//       return handleError(res, err);
-//     });
-//   })
-//   .catch(function(err) {
-//     return handleError(res, err);
-//   });
-// };
-//
-// // Deletes a widget from the DB.
-// exports.destroy = function(req, res) {
-//   Widget
-//   .find({
-//     where: {
-//       id: req.params.id
-//     }
-//   })
-//   .then(function (widget) {
-//     if(!widget) { return res.sendStatus(404); }
-//     widget.destroy()
-//     .then(function() {
-//       return res.sendStatus(204);
-//     })
-//     .catch(function(err) {
-//       return handleError(res, err);
-//     });
-//   })
-//   .catch(function(err) {
-//     return handleError(res, err);
-//   });
-// };
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/widget/widget.spec.js b/server/api/widget/widget.spec.js
index 94ea420..0fbdd19 100644
--- a/server/api/widget/widget.spec.js
+++ b/server/api/widget/widget.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/widgets', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/widgets')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/xchatty/index.js b/server/api/xchatty/index.js
index aa25480..a48bcaa 100644
--- a/server/api/xchatty/index.js
+++ b/server/api/xchatty/index.js
@@ -1,29 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./xchatty.controller');
-
-var router = express.Router();
-
-router.get('/jquery', controller.getJqueryLibrary);
-router.get('/assets', controller.getAssets);
-
-router.get('/status', controller.getStatus);
-router.get('/signup', controller.signupCustomer);
-router.get('/read', controller.getMessages);
-router.get('/send', controller.sendMessage);
-router.get('/signout', controller.signoutCustomer);
-router.get('/submit', controller.submitEnquiry);
-router.get('/unserved', controller.unservedCustomer);
-router.get('/transcript', controller.getTranscript);
-
-router.get('/:id', controller.getJsByWebsite);
-router.get('/:id/styles', controller.getStyleByWebsite);
-
-// router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/xchatty/xchatty.controller.js b/server/api/xchatty/xchatty.controller.js
index 17a3330..1c81eaf 100644
--- a/server/api/xchatty/xchatty.controller.js
+++ b/server/api/xchatty/xchatty.controller.js
@@ -1,566 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var jsmin = require('jsmin').jsmin;
-var Mustache = require('mustache');
-var querystring = require('querystring');
-var path = require('path');
-var md5 = require('md5');
-var fs = require('fs');
-var UAParser = require('ua-parser-js');
-var uaParser = new UAParser();
-var languageParser = require('accept-language-parser');
-var ipaddr = require('ipaddr.js');
-var geoip = require('geoip-lite');
-var csv = require('to-csv')
-
-var config = require('../../config/environment');
-var Xchatty = require('../../models').Xchatty;
-var xchatty_components = require('../../components/xchatty');
-
-var sequelize = require('../../models').sequelize;
-var User = require('../../models').User;
-var Agent = require('../../models').User;
-var ChatRoom = require('../../models').ChatRoom;
-var ChatEnquiry = require('../../models').ChatEnquiry;
-var ChatVisitor = require('../../models').ChatVisitor;
-var ChatMessage = require('../../models').ChatMessage;
-var ChatWebsite = require('../../models').ChatWebsite;
-
-var id = 1;
-
-// var ip = addr.toIPv4Address().octets.join('.');
-
-// Get list of xchattys
-exports.index = function (req, res, next) {
-  Xchatty
-    .findAll()
-    .then(function (xchattys) {
-      return res.status(200).send(xchattys);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-exports.getJsByWebsite = function (req, res, next) {
-
-  // TO DO: Find the configuration of the website and replace configuration in the file
-  ChatWebsite
-    .findById(req.params.id)
-    .then(function (chatWebsite) {
-      res.set({
-        'Content-Type': 'application/javascript',
-        'x-timestamp': Date.now(),
-        'x-sent': true
-      });
-
-      var js = xchatty_components.js;
-      /*jshint multistr: true */
-      var configJS = {
-        websiteId: req.params.id,
-        // rootPath: path.join(chatWebsite.remote, 'api', 'xchatty/'),
-        rootPath: chatWebsite.remote + '/api/xchatty/',
-        signedUp: 'false',
-        windowFocused: 'false',
-        isNewPage: 'true',
-        processingSignUp: 'false',
-        processingEnquiry: 'false',
-        processingSend: 'false',
-        visitorFullname: '""',
-        visitorAvatar: '""',
-        timerReadMessages: 'null',
-        timerCheckStatus: 'null',
-        isOnline: 'false',
-        decayHistory: 0,
-        defaultTimeout: 2000,
-        isInitialStatusCheck: 'true',
-        muteNotificationSoundOnce: 'false',
-        assetBase: chatWebsite.remote + '/api/xchatty/assets',
-        hasSessionSaf: 'false',
-        restoreOpenState: 'false',
-        animateHover: chatWebsite.animation,
-        hideEmail: 'false',
-        hideOffline: 'false',
-        headerShape: chatWebsite.header_shape,
-        HeaderOnline: chatWebsite.header_online,
-        OnlineMessage: chatWebsite.online_message,
-        UsernamePlaceholder: chatWebsite.username_placeholder,
-        EmailPlaceholder: chatWebsite.email_placeholder,
-        StartChatButtonText: chatWebsite.start_chat_button,
-        OfflineMessage: chatWebsite.offline_message,
-        HeaderOffline: chatWebsite.header_offline,
-        EnquiryMessagePlaceholder: chatWebsite.enquiry_message_placeholder,
-        EnquiryButtonText: chatWebsite.enquiry_button,
-        downloadTranscript: chatWebsite.download_transcript
-      };
-
-      js = Mustache.render(js, configJS);
-      res.send(js);
-
-    })
-    .catch(function (err) {
-      next(err);
-    });
-
-};
-
-exports.getStyleByWebsite = function (req, res, next) {
-
-  // TO DO: Find the configuration of the website and replace configuration in the file
-  ChatWebsite
-    .findById(req.params.id)
-    .then(function (chatWebsite) {
-
-      res.set({
-        'Content-Type': 'text/css',
-        'x-timestamp': Date.now(),
-        'x-sent': true
-      });
-
-      var css = xchatty_components.css;
-
-      var configCSS = {
-        // assetBase: path.join(chatWebsite.remote, 'api', 'xchatty',
-        //   'assets'),
-        assetBase: chatWebsite.remote + '/api/xchatty/assets',
-        color: chatWebsite.color,
-        colorFocus: chatWebsite.color_focus,
-        colorButton: chatWebsite.color_button
-      };
-
-      css = Mustache.render(css, configCSS);
-      res.send(css);
-    })
-    .catch(function (err) {
-      next(err);
-    });
-};
-
-exports.getAssets = function (req, res, next) {
-  res.download(path.join(config.root, 'server', 'components', 'xchatty', 'assets', req.query.resource));
-};
-
-exports.getJqueryLibrary = function (req, res, next) {
-
-  // TODO: Find the configuration of the website and replace configuration in the file
-  res.set({
-    'Content-Type': 'application/javascript',
-    'x-timestamp': Date.now(),
-    'x-sent': true
-  });
-
-  var jquery = xchatty_components.jquery;
-  res.send(jquery);
-
-};
-
-exports.getStatus = function (req, res, next) {
-
-  if (!req.session.xchatty) {
-    req.session.xchatty = {};
-  }
-  // Get all users (later agents) online in the interface
-  Agent
-    .findAll({
-      where: {
-        online: true,
-        role: 'agent'
-      }
-    })
-    .then(function (users) {
-
-      if (req.query.data.open_state)
-        req.session.xchatty.open_state = req.query.data.open_state === 'true' ? true : false;
-
-      var jsonResponse = {
-        success: true,
-        has_session_saf: null,
-        signed_up: req.session.xchatty.room_id ? true : false,
-        fullname: req.session.xchatty.fullname ? req.session.xchatty.fullname : '',
-        email: req.session.xchatty.email ? req.session.xchatty.email : '',
-        avatar: req.session.xchatty.avatar ? req.session.xchatty.avatar : '',
-        open_state: req.session.xchatty.open_state || req.session.xchatty.room_id ? true : false,
-        online: users.length ? true : false
-      };
-
-      if (req.session.xchatty.visitor_id) {
-        ChatRoom
-          .findOne({
-            where: {
-              ChatVisitorId: req.session.xchatty.visitor_id,
-              status: 'open'
-            }
-          })
-          .then(function (chatRoom) {
-            if (chatRoom) {
-              req.session.xchatty.room_id = chatRoom.id;
-              jsonResponse.signed_up = true;
-            } else {
-              jsonResponse.signed_up = false;
-            }
-
-            res.send(req.query.callback + '(' + JSON.stringify(jsonResponse) + ')');
-          })
-          .catch(function (err) {
-            next(err);
-          });
-      } else {
-        res.send(req.query.callback + '(' + JSON.stringify(jsonResponse) + ')');
-      }
-
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-exports.getMessages = function (req, res, next) {
-
-  /*jshint multistr: true */
-  var condition = {
-    where: {
-      ChatRoomId: req.session.xchatty.room_id
-    },
-    include: [{
-      model: User,
-      attributes: ['id', 'name', 'fullname', 'email']
-    }, {
-      model: ChatVisitor,
-      attributes: ['id', 'fullname', 'email']
-    }]
-  };
-
-  if (req.query.data.is_new_page === 'false') {
-    condition.where.id = {
-      $gt: req.query.data.last_id
-    };
-  }
-
-  ChatMessage
-    .findAll(condition)
-    .then(function (chatMessages) {
-      var json = {
-        success: true,
-        messages: chatMessages,
-        composing: false,
-        composing_fullname: null
-      };
-
-      res.send(req.query.callback + '(' + JSON.stringify(json) + ')');
-    })
-    .catch(function (err) {
-      next(err);
-    });
-};
-
-exports.sendMessage = function (req, res, next) {
-
-  /*jshint multistr: true */
-  var condition = {
-    where: {
-      ChatRoomId: req.session.xchatty.room_id
-    },
-    include: [{
-      model: User,
-      attributes: ['id', 'name', 'fullname', 'email']
-    }, {
-      model: ChatVisitor,
-      attributes: ['id', 'fullname', 'email']
-    }]
-  };
-
-  if (req.query.data.is_new_page === 'false') {
-    condition.where.id = {
-      $gt: req.query.data.last_id
-    };
-  }
-
-  ChatMessage
-    .create({
-      body: req.query.data.Message.message,
-      ChatRoomId: req.session.xchatty.room_id,
-      ChatVisitorId: req.session.xchatty.visitor_id
-    })
-    .then(function (chatMessage) {
-      console.log('chatMessage', chatMessage);
-      ChatMessage
-        .findAll(condition)
-        .then(function (chatMessages) {
-          var json = {
-            errors: [],
-            success: true,
-            data: chatMessage,
-            messages: chatMessages
-          };
-
-          res.send(req.query.callback + '(' + JSON.stringify(json) + ')');
-        })
-        .catch(function (err) {
-          next(err);
-        });
-    })
-    .catch(function (err) {
-      next(err);
-    });
-
-};
-
-exports.signoutCustomer = function (req, res, next) {
-
-  ChatRoom
-    .findById(req.session.xchatty.room_id)
-    .then(function (chatRoom) {
-      chatRoom.updateAttributes({
-          status: 'close'
-        })
-        .then(function (chatRoom) {
-          var json = {
-            success: true,
-            errors: []
-          };
-          req.session.xchatty = {};
-          res.send(req.query.callback + '(' + JSON.stringify(json) + ')');
-        })
-        .catch(function (err) {
-          next(err);
-        })
-    })
-    .catch(function (err) {
-      next(err);
-    });
-};
-
-exports.signupCustomer = function (req, res, next) {
-  var ua = uaParser.setUA(req.headers['user-agent']).getResult();
-  var languages = languageParser.parse(req.headers['accept-language']);
-  // var addr = ipaddr.parse(req.connection.remoteAddress);
-
-  // var ipv4Addr = "151.0.175.186";
-  // var geo = geoip.lookup(ipv4Addr);
-
-  var body = {
-    fullname: req.query.data.Discussion.fullname,
-    email: req.query.data.Discussion.email,
-    // remote_address: addr,
-    remote_address: req.connection.remoteAddress,
-    user_agent: req.headers['user-agent'],
-    visitor_language: req.headers['accept-language'],
-    referer: req.headers.referer,
-    origin: 'webchat',
-    browser: ua.browser.name + ' ' + ua.browser.version,
-    engine: ua.engine.name + ' ' + ua.engine.version,
-    os: ua.os.name + ' ' + ua.os.version,
-    device: ua.device.model ? ua.device.model + ' ' + ua.device.vendor + ' ' + ua.device.type : null,
-    // country: geo.country,
-    // city: geo.city,
-    // region: geo.region,
-    // latitude: geo.ll.length ? geo.ll[0].toString() : null,
-    // longitude: geo.ll.length ? geo.ll[1].toString() : null,
-    ChatWebsiteId: req.query.chatWebsiteId
-  };
-
-  return ChatVisitor
-    .create(body)
-    .then(function (chatVisitor) {
-
-      req.session.xchatty.fullname = chatVisitor.fullname;
-      req.session.xchatty.email = chatVisitor.email;
-      req.session.xchatty.avatar = md5(chatVisitor.email).toString('base64');
-      req.session.xchatty.visitor_id = chatVisitor.id;
-
-      var json = {
-        success: true,
-        errors: [],
-        chatVisitor: {
-          id: chatVisitor.id
-        }
-      };
-
-      /*jshint multistr: true */
-      res.send(req.query.callback + '(' + JSON.stringify(json) + ')');
-    })
-    .catch(function (err) {
-      next(err);
-    });
-};
-
-exports.unservedCustomer = function (req, res, next) {
-
-  ChatVisitor
-    .findById(req.session.xchatty.visitor_id)
-    .then(function (chatVisitor) {
-
-      chatVisitor.updateAttributes({
-          status: 'unserved'
-        }).then(function () {
-          var json = {
-            success: true,
-            errors: []
-          };
-          req.session.xchatty = {};
-          res.send(req.query.callback + '(' + JSON.stringify(json) + ')');
-        })
-        .catch(function (err) {
-          next(err);
-        });
-    })
-    .catch(function (err) {
-      next(err);
-    });
-};
-
-exports.submitEnquiry = function (req, res, next) {
-
-  var _chatVisitor;
-  var _chatEnquiry;
-
-  return sequelize.transaction().then(function (t) {
-
-    return ChatVisitor
-      .create({
-        fullname: req.query.data.Enquiry.fullname,
-        email: req.query.data.Enquiry.email,
-        remote_address: req.connection.remoteAddress,
-        user_agent: req.headers['user-agent'],
-        visitor_language: req.headers['accept-language'],
-        referer: req.headers.referer,
-        origin: 'enquiry',
-        status: 'unserved'
-      }, {
-        transaction: t
-      })
-      .then(function (chatVisitor) {
-        _chatVisitor = chatVisitor;
-        return ChatEnquiry
-          .create({
-            username: req.query.data.Enquiry.fullname,
-            email: chatVisitor.email,
-            text: req.query.data.Enquiry.message,
-            ChatWebsiteId: parseInt(req.query.data.Enquiry.websiteId, 10),
-            ChatVisitorId: _chatVisitor.id
-          }, {
-            include: [{
-              all: true,
-              include: [{
-                all: true
-              }]
-            }],
-            transaction: t
-          });
-      })
-      .then(function () {
-        t.commit();
-        res.send(req.query.callback + '(' + JSON.stringify({
-          success: true,
-          errors: []
-        }) + ')');
-      })
-      .catch(function (err) {
-        t.rollback();
-        next(err);
-      });
-  });
-};
-
-exports.getTranscript = function (req, res, next) {
-  if (req.session.xchatty && req.session.xchatty.visitor_id && req.session.xchatty
-    .room_id) {
-    ChatMessage
-      .findAll({
-        where: {
-          ChatRoomId: req.session.xchatty.room_id
-        }
-      })
-      .then(function (chatMessages) {
-
-        var chatMessageForCSV = [];
-        chatMessages.forEach(function (chatMessage) {
-          var chatMsg = {
-            name: chatMessage.fullname,
-            text: chatMessage.body.replace(/(\r\n|\n|\r)/gm, " "),
-            date: chatMessage.createdAt
-          };
-          chatMessageForCSV.push(chatMsg);
-        });
-        var csv_transcript = csv(chatMessageForCSV);
-        res.type('text/csv').status(200).send(csv_transcript);
-      })
-      .catch(function (err) {
-        next(err);
-      });
-  }
-};
-
-// Get a single xchatty
-exports.show = function (req, res, next) {
-  Xchatty
-    .findById(req.params.id)
-    .then(function (xchatty) {
-      if (!xchatty) {
-        return res.sendStatus(404);
-      }
-      return res.send(xchatty);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Creates a new xchatty in the DB.
-exports.create = function (req, res, next) {
-  Xchatty
-    .create(req.body)
-    .then(function (xchatty) {
-      return res.status(201).send(xchatty);
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Updates an existing xchatty in the DB.
-exports.update = function (req, res, next) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  Xchatty
-    .findById(req.params.id)
-    .then(function (xchatty) {
-      if (!xchatty) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(xchatty, req.body);
-      updated.save()
-        .then(function () {
-          return res.status(200).send(xchatty);
-        })
-        .catch(function (err) {
-          return next(err);
-        });
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
-
-// Deletes a xchatty from the DB.
-exports.destroy = function (req, res, next) {
-  Xchatty
-    .findById(req.params.id)
-    .then(function (xchatty) {
-      if (!xchatty) {
-        return res.sendStatus(404);
-      }
-      xchatty.destroy()
-        .then(function () {
-          return res.sendStatus(204);
-        })
-        .catch(function (err) {
-          return next(err);
-        });
-    })
-    .catch(function (err) {
-      return next(err);
-    });
-};
\ No newline at end of file
diff --git a/server/api/xchatty/xchatty.socket.js b/server/api/xchatty/xchatty.socket.js
index b8ec557..fcf9a07 100644
--- a/server/api/xchatty/xchatty.socket.js
+++ b/server/api/xchatty/xchatty.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var xchatty = require('../../models').Xchatty;
-
-exports.register = function(socket) {
-  // xchatty.afterCreate(function (doc) {
-  //   onSave(socket, doc);
-  // });
-  // xchatty.afterDestroy(function (doc) {
-  //   onRemove(socket, doc);
-  // });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('xchatty:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('xchatty:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/zendesk_account/index.js b/server/api/zendesk_account/index.js
index d64cd4a..afaa9c9 100644
--- a/server/api/zendesk_account/index.js
+++ b/server/api/zendesk_account/index.js
@@ -1,20 +1 @@
-'use strict';
-
-var express = require('express');
-var auth = require('../../auth/auth.service');
-var controller = require('./zendesk_account.controller');
-
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.get('/:id/check', auth.isAuthenticated(), controller.checkAccount);
-router.get('/:id/fields', auth.isAuthenticated(), controller.getFields);
-router.post('/validate/:field', auth.isAuthenticated(), controller.zendeskValidation);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/', auth.isAuthenticated(), controller.bulkDestroy);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/zendesk_account/zendesk_account.controller.js b/server/api/zendesk_account/zendesk_account.controller.js
index 2cac790..3f84597 100644
--- a/server/api/zendesk_account/zendesk_account.controller.js
+++ b/server/api/zendesk_account/zendesk_account.controller.js
@@ -1,253 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var zendesk = require('node-zendesk');
-
-var ZendeskAccount = require('../../models').ZendeskAccount;
-
-// Get list of zendesk_accounts
-exports.index = function(req, res, next) {
-
-  var attributes = ['description', 'name', 'username', 'remoteUri'];
-  var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
-  var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
-  var query = {
-    where: {},
-    limit: per_page,
-    offset: page * per_page
-  };
-
-  _.forIn(req.query, function(value, key) {
-    switch (key) {
-      case 'per_page':
-      case 'page':
-        break;
-      case 'sort_by':
-        query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
-        break;
-      case 'sort_order':
-        break;
-      case '$':
-        query.where.$or = [];
-        attributes.forEach(function(attribute) {
-          var tmp = {};
-          tmp[attribute] = {
-            $like: '%' + value + '%'
-          };
-
-          query.where.$or.push(tmp);
-        });
-        break;
-      default:
-        query.where[key] = {
-          $like: {}
-        };
-        query.where[key].$like = '%' + value + '%';
-    }
-  });
-
-  ZendeskAccount
-    .findAndCountAll(query)
-    .then(function(result) {
-
-      var total_pages = Math.ceil(result.count / per_page);
-      var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
-      var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
-      return res.status(200).send({
-        count: result.count,
-        rows: result.rows,
-        next_page: next_page,
-        previous_page: previous_page,
-        total_pages: total_pages
-      });
-
-    })
-    .catch(function(err) {
-      return res.status(500).send({
-        error: 'Something blew up!'
-      });
-    });
-};
-
-// Get a single zendesk_account
-exports.show = function(req, res) {
-  ZendeskAccount
-    .findById(req.params.id)
-    .then(function(zendesk_account) {
-      if (!zendesk_account) {
-        return res.sendStatus(404);
-      }
-      return res.send(zendesk_account);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new zendesk_account in the DB.
-exports.create = function(req, res) {
-  ZendeskAccount
-    .create(req.body)
-    .then(function(zendesk_account) {
-      return res.status(201).send(zendesk_account);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing zendesk_account in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ZendeskAccount
-    .findById(req.params.id)
-    .then(function(zendesk_account) {
-      if (!zendesk_account) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(zendesk_account, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(zendesk_account);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a zendesk_account from the DB.
-exports.destroy = function(req, res) {
-  ZendeskAccount
-    .findById(req.params.id)
-    .then(function(zendesk_account) {
-      if (!zendesk_account) {
-        return res.sendStatus(404);
-      }
-      zendesk_account.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.bulkDestroy = function(req, res) {
-  ZendeskAccount
-    .destroy({
-      where: {
-        id: req.query.id
-      },
-      individualHooks: true
-    })
-    .then(function() {
-      return res.sendStatus(204);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.zendeskValidation = function(req, res) {
-  var where = {};
-  where[req.params.field] = req.body.value;
-  ZendeskAccount
-    .findAndCountAll({
-      where: where
-    })
-    .then(function(result) {
-      if (result.count) {
-        return res.status(200).send({
-          isValid: false,
-          value: req.body.value
-        });
-      }
-      return res.status(200).send({
-        isValid: true,
-        value: req.body.value
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-
-};
-
-exports.checkAccount = function(req, res) {
-  ZendeskAccount
-    .findById(req.params.id)
-    .then(function(account) {
-      var accountZendesk = {
-        username: account.username,
-        remoteUri: account.remoteUri,
-        // debug: true
-      };
-      if (account.authType === 'password') {
-        accountZendesk.password = account.password;
-      } else if (account.authType === 'token') {
-        accountZendesk.token = account.token;
-        // accountZendesk.oauth = true;
-      }
-      // console.log(accountZendesk);
-      var client = zendesk.createClient(accountZendesk);
-      client.users.auth(function(err, res2, result) {
-        if (err) {
-          console.error(err);
-          return handleError(res, err);
-        }
-        // console.log(result);
-        if (!result.verified) {
-          return res.sendStatus(500);
-        }
-        return res.sendStatus(204);
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.getFields = function(req, res) {
-  ZendeskAccount
-    .findById(req.params.id)
-    .then(function(account) {
-      var accountZendesk = {
-        username: account.username,
-        remoteUri: account.remoteUri,
-        // debug: true
-      };
-      if (account.authType === 'password') {
-        accountZendesk.password = account.password;
-      } else if (account.authType === 'token') {
-        accountZendesk.token = account.token;
-      }
-      var client = zendesk.createClient(accountZendesk);
-      client.ticketfields.list(function(err, res2, result) {
-        if (err) {
-          console.error(err);
-          return handleError(res, err);
-        }
-        return res.status(200).send(result);
-      });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-}
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/zendesk_account/zendesk_account.socket.js b/server/api/zendesk_account/zendesk_account.socket.js
index 96c8214..f70b862 100644
--- a/server/api/zendesk_account/zendesk_account.socket.js
+++ b/server/api/zendesk_account/zendesk_account.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ZendeskAccount = require('../../models').ZendeskAccount;
-
-exports.register = function(socket) {
-  ZendeskAccount.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  ZendeskAccount.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('zendesk_account:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('zendesk_account:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/zendesk_account/zendesk_account.spec.js b/server/api/zendesk_account/zendesk_account.spec.js
index 68c8389..732f4c5 100644
--- a/server/api/zendesk_account/zendesk_account.spec.js
+++ b/server/api/zendesk_account/zendesk_account.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/zendesk/accounts', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/zendesk/accounts')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/zendesk_configuration/index.js b/server/api/zendesk_configuration/index.js
index 9df7d1b..03cb650 100644
--- a/server/api/zendesk_configuration/index.js
+++ b/server/api/zendesk_configuration/index.js
@@ -1,16 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./zendesk_configuration.controller');
-var auth = require('../../auth/auth.service');
-var router = express.Router();
-
-router.get('/', auth.isAuthenticated(), controller.index);
-router.get('/:id', auth.isAuthenticated(), controller.show);
-router.post('/', auth.isAuthenticated(), controller.create);
-router.put('/:id', auth.isAuthenticated(), controller.update);
-router.post('/:id/:type', auth.isAuthenticated(), controller.addConfigurationField);
-router.patch('/:id', auth.isAuthenticated(), controller.update);
-router.delete('/:id', auth.isAuthenticated(), controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/zendesk_configuration/zendesk_configuration.controller.js b/server/api/zendesk_configuration/zendesk_configuration.controller.js
index 1bcfaae..3ea1035 100644
--- a/server/api/zendesk_configuration/zendesk_configuration.controller.js
+++ b/server/api/zendesk_configuration/zendesk_configuration.controller.js
@@ -1,162 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ZendeskConfiguration = require('../../models').ZendeskConfiguration;
-var ZendeskField = require('../../models').ZendeskField;
-
-// Get list of zendesk_configurations
-exports.index = function(req, res) {
-  ZendeskConfiguration
-    .findAll({
-      where: req.query
-    })
-    .then(function(zendesk_configurations) {
-      return res.status(200).send(zendesk_configurations);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single zendesk_configuration
-exports.show = function(req, res) {
-  ZendeskConfiguration
-    .find({
-      where: {
-        id: req.params.id
-      },
-      include: [{
-        model: ZendeskField,
-        as: 'Subject'
-      }, {
-        model: ZendeskField,
-        as: 'Description'
-      }, {
-        model: ZendeskField,
-        as: 'Field'
-      }]
-    })
-    .then(function(zendesk_configuration) {
-      if (!zendesk_configuration) {
-        return res.sendStatus(404);
-      }
-      return res.send(zendesk_configuration);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new zendesk_configuration in the DB.
-exports.create = function(req, res) {
-  ZendeskConfiguration
-    .create(req.body)
-    .then(function(zendesk_configuration) {
-      return res.status(201).send(zendesk_configuration);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing zendesk_configuration in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ZendeskConfiguration
-    .findById(req.params.id)
-    .then(function(zendesk_configuration) {
-      if (!zendesk_configuration) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(zendesk_configuration, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(zendesk_configuration);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a zendesk_configuration from the DB.
-exports.destroy = function(req, res) {
-  ZendeskConfiguration
-    .findById(req.params.id)
-    .then(function(zendesk_configuration) {
-      if (!zendesk_configuration) {
-        return res.sendStatus(404);
-      }
-      zendesk_configuration.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.addConfigurationField = function(req, res, next) {
-  // console.log(req.params);
-  ZendeskConfiguration
-    .findById(req.params.id)
-    .then(function(configuration) {
-      if (!configuration) {
-        return res.sendStatus(500);
-      }
-      ZendeskField
-        .create(req.body)
-        .then(function(field) {
-          switch (req.params.type) {
-            case 'subject':
-              configuration.addSubject(field)
-                .then(function() {
-                  return res.status(200).send(field);
-                })
-                .catch(function(err) {
-                  return handleError(res, err);
-                });
-              break;
-            case 'description':
-              configuration.addDescription(field)
-                .then(function() {
-                  return res.status(200).send(field);
-                })
-                .catch(function(err) {
-                  return handleError(res, err);
-                });
-              break;
-            case 'field':
-              configuration.addField(field)
-                .then(function() {
-                  return res.status(200).send(field);
-                })
-                .catch(function(err) {
-                  return handleError(res, err);
-                });
-              break;
-          }
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-          // return next(err);
-        });
-    })
-    .catch(function(err) {
-      // return next(err);
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/zendesk_configuration/zendesk_configuration.socket.js b/server/api/zendesk_configuration/zendesk_configuration.socket.js
index d9a56f1..8cc2168 100644
--- a/server/api/zendesk_configuration/zendesk_configuration.socket.js
+++ b/server/api/zendesk_configuration/zendesk_configuration.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ZendeskConfiguration = require('../../models').ZendeskConfiguration;
-
-exports.register = function(socket) {
-  ZendeskConfiguration.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  ZendeskConfiguration.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('zendesk_configuration:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('zendesk_configuration:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/zendesk_configuration/zendesk_configuration.spec.js b/server/api/zendesk_configuration/zendesk_configuration.spec.js
index 3589f5d..1ce70b3 100644
--- a/server/api/zendesk_configuration/zendesk_configuration.spec.js
+++ b/server/api/zendesk_configuration/zendesk_configuration.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/zendesk/configurations', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/zendesk/configurations')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
\ No newline at end of file
diff --git a/server/api/zendesk_field/index.js b/server/api/zendesk_field/index.js
index 76f5c48..6de3318 100644
--- a/server/api/zendesk_field/index.js
+++ b/server/api/zendesk_field/index.js
@@ -1,15 +1 @@
-'use strict';
-
-var express = require('express');
-var controller = require('./zendesk_field.controller');
-
-var router = express.Router();
-
-router.get('/', controller.index);
-router.get('/:id', controller.show);
-router.post('/', controller.create);
-router.put('/:id', controller.update);
-router.patch('/:id', controller.update);
-router.delete('/:id', controller.destroy);
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/api/zendesk_field/zendesk_field.controller.js b/server/api/zendesk_field/zendesk_field.controller.js
index 48d0c38..91e6ced 100644
--- a/server/api/zendesk_field/zendesk_field.controller.js
+++ b/server/api/zendesk_field/zendesk_field.controller.js
@@ -1,93 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var ZendeskField = require('../../models').ZendeskField;
-
-// Get list of zendesk_fields
-exports.index = function(req, res) {
-  ZendeskField
-    .findAll()
-    .then(function(zendesk_fields) {
-      return res.status(200).send(zendesk_fields);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Get a single zendesk_field
-exports.show = function(req, res) {
-  ZendeskField
-    .findById(req.params.id)
-    .then(function(zendesk_field) {
-      if (!zendesk_field) {
-        return res.sendStatus(404);
-      }
-      return res.send(zendesk_field);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Creates a new zendesk_field in the DB.
-exports.create = function(req, res) {
-  ZendeskField
-    .create(req.body)
-    .then(function(zendesk_field) {
-      return res.status(201).send(zendesk_field);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Updates an existing zendesk_field in the DB.
-exports.update = function(req, res) {
-  if (req.body.id) {
-    delete req.body.id;
-  }
-  ZendeskField
-    .findById(req.params.id)
-    .then(function(zendesk_field) {
-      if (!zendesk_field) {
-        return res.sendStatus(404);
-      }
-      var updated = _.merge(zendesk_field, req.body);
-      updated.save()
-        .then(function() {
-          return res.status(200).send(zendesk_field);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// Deletes a zendesk_field from the DB.
-exports.destroy = function(req, res) {
-  ZendeskField
-    .findById(req.params.id)
-    .then(function(zendesk_field) {
-      if (!zendesk_field) {
-        return res.sendStatus(404);
-      }
-      zendesk_field.destroy()
-        .then(function() {
-          return res.sendStatus(204);
-        })
-        .catch(function(err) {
-          return handleError(res, err);
-        });
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
\ No newline at end of file
diff --git a/server/api/zendesk_field/zendesk_field.socket.js b/server/api/zendesk_field/zendesk_field.socket.js
index 8a5419b..1d52384 100644
--- a/server/api/zendesk_field/zendesk_field.socket.js
+++ b/server/api/zendesk_field/zendesk_field.socket.js
@@ -1,24 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var ZendeskField = require('../../models').ZendeskField;
-
-exports.register = function(socket) {
-  ZendeskField.afterCreate(function(doc) {
-    onSave(socket, doc);
-  });
-  ZendeskField.afterDestroy(function(doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc, cb) {
-  socket.emit('zendesk_field:save', doc);
-}
-
-function onRemove(socket, doc, cb) {
-  socket.emit('zendesk_field:remove', doc);
-}
\ No newline at end of file
diff --git a/server/api/zendesk_field/zendesk_field.spec.js b/server/api/zendesk_field/zendesk_field.spec.js
index 1527fe8..c275632 100644
--- a/server/api/zendesk_field/zendesk_field.spec.js
+++ b/server/api/zendesk_field/zendesk_field.spec.js
@@ -1,20 +1 @@
-'use strict';
-
-var should = require('should');
-var app = require('../../app');
-var request = require('supertest');
-
-describe('GET /api/zendesk/fields', function() {
-
-  it('should respond with JSON array', function(done) {
-    request(app)
-      .get('/api/zendesk/fields')
-      .expect(200)
-      .expect('Content-Type', /json/)
-      .end(function(err, res) {
-        if (err) return done(err);
-        res.body.should.be.instanceof(Array);
-        done();
-      });
-  });
-});
\ No newline at end of file
diff --git a/server/app.js b/server/app.js
index 57d32fb..5fdd9e7 100644
--- a/server/app.js
+++ b/server/app.js
@@ -1,12 +1 @@
\ No newline at end of file
\ No newline at end of file
diff --git a/server/auth/auth.service.js b/server/auth/auth.service.js
index 277a546..45f528a 100644
--- a/server/auth/auth.service.js
+++ b/server/auth/auth.service.js
@@ -1,90 +1 @@
-'use strict';
-
-//var mongoose = require('mongoose');
-var passport = require('passport');
-var config = require('../config/environment');
-var jwt = require('jsonwebtoken');
-var expressJwt = require('express-jwt');
-var compose = require('composable-middleware');
-// var User = require('../api/user/user.model');
-var User = require('../models').User;
-var validateJwt = expressJwt({
-  secret: config.session.secret
-});
-
-/**
- * Attaches the user object to the request if authenticated
- * Otherwise returns 403
- */
-function isAuthenticated() {
-  return compose()
-    // Validate jwt
-    .use(function(req, res, next) {
-      // allow access_token to be passed through query parameter as well
-      if (req.query && req.query.hasOwnProperty('access_token')) {
-        req.headers.authorization = 'Bearer ' + req.query.access_token;
-      }
-      validateJwt(req, res, next);
-    })
-    // Attach user to request
-    .use(function(req, res, next) {
-      User
-        .findById(req.user.id)
-        .then(function(user) {
-          if (!user) return res.send(401);
-          req.user = user;
-          return next();
-        })
-        .catch(function(err) {
-          return next(err);
-        });
-    });
-}
-
-/**
- * Checks if the user role meets the minimum requirements of the route
- */
-function hasRole(roleRequired) {
-  if (!roleRequired) throw new Error('Required role needs to be set');
-
-  return compose()
-    .use(isAuthenticated())
-    .use(function meetsRequirements(req, res, next) {
-      if (config.userRoles.indexOf(req.user.role) >= config.userRoles.indexOf(roleRequired)) {
-        return next();
-      } else {
-        return res.send(403);
-      }
-    });
-}
-
-/**
- * Returns a jwt token signed by the app secret
- */
-function signToken(id, role, remember) {
-  var expiresIn = 60 * 24 * 365 * 5; //If remember, it expires in 5 years
-  if (!remember)
-    expiresIn = "1d"; //Expire in one day
-  return jwt.sign({
-    id: id
-  }, config.session.secret, {
-    expiresIn: expiresIn
-  });
-}
-
-/**
- * Set token cookie directly for oAuth strategies
- */
-function setTokenCookie(req, res) {
-  if (!req.user) return res.json(404, {
-    message: 'Something went wrong, please try again.'
-  });
-  var token = signToken(req.user.id, req.user.role);
-  res.cookie('token', JSON.stringify(token));
-  res.redirect('/');
-}
-
-exports.isAuthenticated = isAuthenticated;
-exports.hasRole = hasRole;
-exports.signToken = signToken;
-exports.setTokenCookie = setTokenCookie;
\ No newline at end of file
diff --git a/server/auth/facebook/index.js b/server/auth/facebook/index.js
index 4a6f878..7178215 100644
--- a/server/auth/facebook/index.js
+++ b/server/auth/facebook/index.js
@@ -1,21 +1 @@
-'use strict';
-
-var express = require('express');
-var passport = require('passport');
-var auth = require('../auth.service');
-
-var router = express.Router();
-
-router
-  .get('/', passport.authenticate('facebook', {
-    scope: ['email', 'user_about_me'],
-    failureRedirect: '/signup',
-    session: false
-  }))
-
-  .get('/callback', passport.authenticate('facebook', {
-    failureRedirect: '/signup',
-    session: false
-  }), auth.setTokenCookie);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/auth/facebook/passport.js b/server/auth/facebook/passport.js
index 90ae489..03948df 100644
--- a/server/auth/facebook/passport.js
+++ b/server/auth/facebook/passport.js
@@ -1,37 +1 @@
-var passport = require('passport');
-var FacebookStrategy = require('passport-facebook').Strategy;
-
-exports.setup = function (User, config) {
-  passport.use(new FacebookStrategy({
-      clientID: config.facebook.clientID,
-      clientSecret: config.facebook.clientSecret,
-      callbackURL: config.facebook.callbackURL
-    },
-    function(accessToken, refreshToken, profile, done) {
-      User.findOne({
-        'facebook.id': profile.id
-      },
-      function(err, user) {
-        if (err) {
-          return done(err);
-        }
-        if (!user) {
-          user = new User({
-            name: profile.displayName,
-            email: profile.emails[0].value,
-            role: 'user',
-            username: profile.username,
-            provider: 'facebook',
-            facebook: profile._json
-          });
-          user.save(function(err) {
-            if (err) done(err);
-            return done(err, user);
-          });
-        } else {
-          return done(err, user);
-        }
-      })
-    }
-  ));
-};
\ No newline at end of file
\ No newline at end of file
diff --git a/server/auth/google/index.js b/server/auth/google/index.js
index 9b1ce39..f8d74bf 100644
--- a/server/auth/google/index.js
+++ b/server/auth/google/index.js
@@ -1,24 +1 @@
-'use strict';
-
-var express = require('express');
-var passport = require('passport');
-var auth = require('../auth.service');
-
-var router = express.Router();
-
-router
-  .get('/', passport.authenticate('google', {
-    failureRedirect: '/signup',
-    scope: [
-      'https://www.googleapis.com/auth/userinfo.profile',
-      'https://www.googleapis.com/auth/userinfo.email'
-    ],
-    session: false
-  }))
-
-  .get('/callback', passport.authenticate('google', {
-    failureRedirect: '/signup',
-    session: false
-  }), auth.setTokenCookie);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/auth/google/passport.js b/server/auth/google/passport.js
index d304e8a..f468001 100644
--- a/server/auth/google/passport.js
+++ b/server/auth/google/passport.js
@@ -1,33 +1 @@
-var passport = require('passport');
-var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
-
-exports.setup = function (User, config) {
-  passport.use(new GoogleStrategy({
-      clientID: config.google.clientID,
-      clientSecret: config.google.clientSecret,
-      callbackURL: config.google.callbackURL
-    },
-    function(accessToken, refreshToken, profile, done) {
-      User.findOne({
-        'google.id': profile.id
-      }, function(err, user) {
-        if (!user) {
-          user = new User({
-            name: profile.displayName,
-            email: profile.emails[0].value,
-            role: 'user',
-            username: profile.username,
-            provider: 'google',
-            google: profile._json
-          });
-          user.save(function(err) {
-            if (err) done(err);
-            return done(err, user);
-          });
-        } else {
-          return done(err, user);
-        }
-      });
-    }
-  ));
-};
\ No newline at end of file
diff --git a/server/auth/index.js b/server/auth/index.js
index a034241..43cdf17 100644
--- a/server/auth/index.js
+++ b/server/auth/index.js
@@ -1,22 +1 @@
-'use strict';
-
-var express   = require('express');
-var passport  = require('passport');
-var config    = require('../config/environment');
-var User      = require('../models').User;
-
-
-// Passport Configuration
-require('./local/passport').setup(User, config);
-require('./facebook/passport').setup(User, config);
-require('./google/passport').setup(User, config);
-require('./twitter/passport').setup(User, config);
-
-var router = express.Router();
-
-router.use('/local', require('./local'));
-router.use('/facebook', require('./facebook'));
-router.use('/twitter', require('./twitter'));
-router.use('/google', require('./google'));
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/auth/local/index.js b/server/auth/local/index.js
index 2c8c113..79b1f74 100644
--- a/server/auth/local/index.js
+++ b/server/auth/local/index.js
@@ -1,92 +1 @@
-'use strict';
-
-var express = require('express');
-var passport = require('passport');
-var async = require('async');
-
-var auth = require('../auth.service');
-var User = require('../../models').User;
-
-var router = express.Router();
-
-router
-  .post('/', function(req, res, next) {
-    passport.authenticate('local-login', function(err, user, info) {
-      var error = err || info;
-      if (error) return res.status(401).json(error);
-      if (!user) return res.status(404).json({
-        message: 'Something went wrong, please try again.'
-      });
-
-      var token = auth.signToken(user.id, user.role, req.body.remember || false);
-
-      User
-        .findById(user.id)
-        .then(function(user) {
-          user
-            .getVoiceQueues({
-              attributes: ['name']
-            })
-            .then(function(voiceQueues) {
-              async.eachSeries(voiceQueues, function iterator(voiceQueue, callback) {
-                require('./local.ami').login(user.id, user.name, voiceQueue.name, callback);
-              }, function done() {
-                return res.json({
-                  token: token,
-                  userId: user.id
-                });
-              });
-            })
-            .catch(function(err) {
-              return next(err);
-            });
-        })
-        .catch(function(err) {
-          return next(err);
-        });
-
-    })(req, res, next)
-  });
-
-router
-  .get('/logout', auth.isAuthenticated(), function(req, res, next) {
-    User
-      .findById(req.user.id)
-      .then(function(user) {
-        user
-          .getVoiceQueues({
-            attributes: ['name']
-          })
-          .then(function(voiceQueues) {
-            async.eachSeries(voiceQueues, function iterator(voiceQueue, callback) {
-              require('./local.ami').logout(req.user.id, req.user.name, voiceQueue.name, callback);
-            }, function done() {
-              req.logout();
-              res.redirect('/');
-            });
-          })
-          .catch(function(err) {
-            return next(err);
-          });
-      })
-      .catch(function(err) {
-        return next(err);
-      });
-
-    // passport.authenticate('local-logout', function(err, user, info) {
-    //   var error = err || info;
-    //   if (error) return res.status(401).json(error);
-    //   if (!user) return res.status(404).json({
-    //     message: 'Something went wrong, please try again.'
-    //   });
-    //
-    //   var token = auth.signToken(user.id, user.role);
-    //   res.json({
-    //     token: token,
-    //     userId: user.id
-    //   });
-    //
-    // })(req, res, next)
-  });
-
-module.exports = router;
\ No newline at end of file
diff --git a/server/auth/local/local.ami.js b/server/auth/local/local.ami.js
index bfb533d..24e4a05 100644
--- a/server/auth/local/local.ami.js
+++ b/server/auth/local/local.ami.js
@@ -1,51 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-
-var util = require('util');
-var amiController = require('../../api/ami/ami.ami');
-
-exports.logout = function(userid, username, queuename, callback) {
-  var body = {
-    action: 'QueuePause',
-    queue: queuename,
-    interface: util.format('SIP/%s', username),
-    paused: false
-  };
-  body.data = JSON.stringify(body);
-  body.UserId = userid;
-
-  amiController.action(body, function(err, res) {
-    if (err) {
-      console.log(err);
-    }
-    var body = {
-      action: 'QueueRemove',
-      queue: queuename,
-      interface: util.format('SIP/%s', username)
-    };
-    body.data = JSON.stringify(body);
-    body.UserId = userid;
-
-    amiController.action(body, callback);
-  });
-}
-
-exports.login = function(userid, username, queuename, callback) {
-
-  var body = {
-    action: 'QueueAdd',
-    queue: queuename,
-    interface: util.format('SIP/%s', username),
-    penalty: 0,
-    paused: false,
-    membername: username
-  };
-
-  body.data = JSON.stringify(body);
-  body.UserId = userid;
-
-  amiController.action(body, callback);
-}
\ No newline at end of file
diff --git a/server/auth/local/passport.js b/server/auth/local/passport.js
index f9a9184..dc061a2 100644
--- a/server/auth/local/passport.js
+++ b/server/auth/local/passport.js
@@ -1,96 +1 @@
-var passport = require('passport');
-var LocalStrategy = require('passport-local').Strategy;
-
-exports.setup = function(User, config) {
-
-  passport.use('local-login', new LocalStrategy({
-      usernameField: 'name',
-      passwordField: 'password' // this is the virtual field on the model
-    },
-    function(name, password, done) {
-
-      User.findOne({
-        where: {
-          name: name
-        }
-      }).then(function(user) {
-
-        if (!user) {
-          return done(null, false, {
-            message: 'This username is not registered.'
-          });
-        }
-        if (!user.authenticate(password)) {
-          return done(null, false, {
-            message: 'This password is not correct.'
-          });
-        }
-        // if (user.online && user.role !== 'admin') {
-        //   console.log('User is already logged in');
-        //   return done(null, false, {
-        //     message: 'User is already logged in.'
-        //   });
-        // }
-
-        // user
-        //   .updateAttributes({
-        //     online: true
-        //   })
-        //   .then(function(user) {
-        return done(null, user);
-        //   })
-        //   .catch(function(err) {
-        //     return done(null, false, {
-        //       message: 'Unable to set up online parameters.'
-        //     });
-        //   });
-      }).catch(function(err) {
-        return done(err);
-      });
-    }
-  ));
-
-  // passport.use('local-signup', new LocalStrategy({
-  //     usernameField: 'name',
-  //     passwordField: 'password',
-  //     passReqToCallback: true
-  //   },
-  //   function(req, name, password, done) {
-  //
-  //     if (!req.user) {
-  //       User
-  //         .findOne({
-  //           where: {
-  //             name: name
-  //           }
-  //         })
-  //         .then(function(user) {
-  //           if (user) {
-  //             return done(null, false, {
-  //               message: 'That email is already taken.'
-  //             });
-  //           } else {
-  //             var newUser = User.build(req.body);
-  //             newUser.provider = 'local';
-  //             newUser.online = true;
-  //             newUser
-  //               .save()
-  //               .then(function() {
-  //                 return done(null, newUser);
-  //               })
-  //               .catch(function(err) {
-  //                 return done(err);
-  //               });
-  //           }
-  //         })
-  //         .catch(function(err) {
-  //           return done(err);
-  //         });
-  //     } else {
-  //       // user is logged in and already has a local account. Ignore signup. (You should log out before trying to create a new account, user!)
-  //       return done(null, req.user);
-  //     }
-  //   }
-  // ));
-
-};
\ No newline at end of file
diff --git a/server/auth/twitter/index.js b/server/auth/twitter/index.js
index 8360247..ad14af0 100644
--- a/server/auth/twitter/index.js
+++ b/server/auth/twitter/index.js
@@ -1,20 +1 @@
-'use strict';
-
-var express = require('express');
-var passport = require('passport');
-var auth = require('../auth.service');
-
-var router = express.Router();
-
-router
-  .get('/', passport.authenticate('twitter', {
-    failureRedirect: '/signup',
-    session: false
-  }))
-
-  .get('/callback', passport.authenticate('twitter', {
-    failureRedirect: '/signup',
-    session: false
-  }), auth.setTokenCookie);
-
-module.exports = router;
\ No newline at end of file
\ No newline at end of file
diff --git a/server/auth/twitter/passport.js b/server/auth/twitter/passport.js
index a2eb4a5..5600fb4 100644
--- a/server/auth/twitter/passport.js
+++ b/server/auth/twitter/passport.js
@@ -1,35 +1 @@
-exports.setup = function (User, config) {
-  var passport = require('passport');
-  var TwitterStrategy = require('passport-twitter').Strategy;
-
-  passport.use(new TwitterStrategy({
-    consumerKey: config.twitter.clientID,
-    consumerSecret: config.twitter.clientSecret,
-    callbackURL: config.twitter.callbackURL
-  },
-  function(token, tokenSecret, profile, done) {
-    User.findOne({
-      'twitter.id_str': profile.id
-    }, function(err, user) {
-      if (err) {
-        return done(err);
-      }
-      if (!user) {
-        user = new User({
-          name: profile.displayName,
-          username: profile.username,
-          role: 'user',
-          provider: 'twitter',
-          twitter: profile._json
-        });
-        user.save(function(err) {
-          if (err) return done(err);
-          return done(err, user);
-        });
-      } else {
-        return done(err, user);
-      }
-    });
-    }
-  ));
-};
\ No newline at end of file
\ No newline at end of file
diff --git a/server/config/agi.js b/server/config/agi.js
index c45091e..77fcf6f 100644
--- a/server/config/agi.js
+++ b/server/config/agi.js
@@ -1,1175 +1 @@
-'use strict';
-
-var _ = require('lodash');
-
-var agi = require('agi');
-var util = require('util');
-var moment = require('moment');
-var xml = require('xml2js');
-var wait = require('wait.for');
-var sr = require('simple-random');
-var path = require('path');
-var config = require('../config/environment');
-var sh = require('shelljs');
-
-var db = require("odbc")();
-
-var SquareProject = require('../models').SquareProject;
-var Variable = require('../models').Variable;
-var SquareOdbc = require('../models').SquareOdbc;
-var Settings = require('../models').Settings;
-var User = require('../models').User;
-var VoiceQueue = require('../models').VoiceQueue;
-var Trunk = require('../models').Trunk;
-var Interval = require('../models').Interval;
-var Upload = require('../models').Upload;
-var ReportSquare = require('../models').ReportSquare;
-var ReportSquareDetail = require('../models').ReportSquareDetail;
-// var TempTable = require('../models').TempTable;
-// var FakeTable = require('../models').FakeTable;
-var users, trunks, variables, intervals, projects, sounds, queues, dbConnections, generalUniqueId;
-var agiPort;
-var weekDaysCollection = {
-  mon: 1,
-  tue: 2,
-  wed: 3,
-  thu: 4,
-  fri: 5,
-  sat: 6,
-  sun: 7
-};
-var monthsCollection = {
-  jan: 1,
-  feb: 2,
-  mar: 3,
-  apr: 4,
-  may: 5,
-  jun: 6,
-  jul: 7,
-  aug: 8,
-  sep: 9,
-  oct: 10,
-  nov: 11,
-  dec: 12
-};
-var methods = {};
-
-methods.answer = function(context, vertex, callback) {
-  console.log('--ANSWER BLOCK--');
-  console.log('Answering the call...');
-  context.send('ANSWER\n', function(err, res) {
-    callback(err, res);
-  });
-};
-
-methods.custom_app = function(context, vertex, callback) {
-  console.log('--CUSTOM APP BLOCK--');
-  console.log('Executing custom app "' + vertex.application + '"...');
-  context.exec(vertex.application, vertex.options, function(err, res) {
-    if (callback) {
-      callback(err, res);
-    }
-  });
-};
-
-
-methods.dial = function(context, vertex, callback) {
-  console.log('--INTERNAL_DIAL BLOCK--');
-  if (!users) {
-    getUsers(false);
-  }
-  var sip = _.find(users, {
-    id: parseInt(vertex.sip_id)
-  });
-  console.log('Calling ' + util.format('SIP/%s', sip.name) + '...');
-  var parameters = [util.format('SIP/%s', sip.name), vertex.timeout, vertex.opts, vertex.url];
-  context.exec('DIAL', parameters.join(','),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.ext_dial = function(context, vertex, callback) {
-  console.log('--EXTERNAL_DIAL BLOCK--');
-  if (!trunks) {
-    getTrunks(false);
-  }
-  var trunk = _.find(trunks, {
-    id: parseInt(vertex.trunk_id)
-  });
-  console.log('Calling ' + util.format('SIP/%s', trunk.name) + '...');
-  var parameters = [util.format('SIP/%s@%s', vertex.phone, trunk.name), vertex.timeout, vertex.opts, vertex.url];
-  context.exec('DIAL', parameters.join(','),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.queue = function(context, vertex, callback) {
-  console.log('--QUEUE BLOCK--');
-  if (!queues) {
-    getQueues(false);
-  }
-  var queue = _.find(queues, {
-    name: vertex.queue_id
-  });
-  var announceOverride = getFilePath(vertex.file_id);
-  var parameters = [queue.name, vertex.opts, vertex.url, announceOverride, vertex.timeout, vertex.agi, vertex.macro, vertex.gosub, '', vertex.position];
-  console.log('Joining ' + queue.name + ' queue...');
-  context.exec('QUEUE', parameters.join(','), function(err, res) {
-    callback(err, res);
-  });
-};
-
-methods.voicemail = function(context, vertex, callback) {
-  console.log('--VOICEMAIL BLOCK--');
-  var parameters = [util.format('%s@%s', vertex.boxnumber, vertex.context), vertex.opts];
-  console.log('Starting voicemail recording...');
-  context.exec('VOICEMAIL', parameters.join(','), function(err, res) {
-    callback(err, res);
-  });
-};
-
-// methods.callback = function(context, vertex, callback) {
-//   context.send('ANSWER\n', function(err, res) {
-//     callback(err, res);
-//   });
-// };
-
-methods.math = function(context, vertex, callback) {
-  console.log('--MATH BLOCK--');
-  console.log('Calculating expression...');
-  var result = eval(vertex.operation);
-  console.log('Saving result in variable...');
-  setVariable(context, vertex.variable_id, result, callback);
-};
-
-// methods.background = function(context, vertex, callback) {
-//   var parameters = [getFilePath(vertex.file_id), vertex.opts];
-//   context.exec('BACKGROUND', parameters.join('|'), function(err, res) {
-//     callback(err, res);
-//   });
-// };
-
-methods.playback = function(context, vertex, callback) {
-  console.log('--PLAYBACK BLOCK--');
-  var audiofile = getFilePath(vertex.file_id);
-  // var audiofile = '/var/www/html/files/sounds/d0269ff87187df665ece75538e4cddfd';
-  var parameters = [audiofile, vertex.opts];
-  console.log('Executing playback...');
-  context.exec('PLAYBACK', parameters.join(','), function(err, res) {
-    callback(err, res);
-  });
-};
-
-methods.menu = function(context, vertex, callback) {
-  console.log('--MENU BLOCK--');
-  var res = {};
-  console.log('There are ' + vertex.retry + ' retries');
-  if (vertex.retry > 0) {
-    vertex.retry--;
-    // var announce = getFilePath(vertex.file_id);
-    var announce = '/var/www/html/files/sounds/b19642d2f71e9cfffbd783fcc79c7415';
-    // console.log(announce);
-    console.log('Announcing and waiting for user entry...');
-    context.send(util.format('GET DATA %s %s %s\n', announce, parseInt(vertex.response) * 1000, vertex.digit),
-      function(err, res) {
-        var squareDetail = {
-          uniqueid: context.uniqueid,
-          node: vertex.label,
-          application: vertex.tag,
-          data: res.result || null
-        }
-        ReportSquareDetail
-          .create(squareDetail)
-          .catch(function(err) {
-            console.log('Error saving ' + vertex.tag + ':' + vertex.label + ' block log', err);
-          });
-        if (res.result !== ' (timeout)') {
-          var variableId = parseInt(vertex.variable_id);
-          if (variableId) {
-            console.log('Saving user entry in a variable...');
-            setVariable(context, variableId, res.result);
-          }
-          res.data = res.result;
-          callback(null, res);
-        } else {
-          console.log('Menu timeout!');
-          res = {
-            code: 200,
-            result: '0',
-            data: 't'
-          };
-          callback(null, res);
-        }
-      });
-
-  } else {
-    console.log('Run out of retries!');
-    res = {
-      code: 200,
-      result: '0',
-      data: '-'
-    };
-    callback(null, res);
-  }
-};
-
-methods.saynumber = function(context, vertex, callback) {
-  console.log('--SAYNUMBER BLOCK--');
-  console.log('Saying number...');
-  context.send(util.format('SAY NUMBER %s "%s"\n', vertex.number, vertex.escape_digits),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.sayphonetic = function(context, vertex, callback) {
-  console.log('--SAYPHONETIC BLOCK--');
-  console.log('Saying phonetic...');
-  context.send(util.format('SAY PHONETIC %s "%s"\n', vertex.text, vertex.escape_digits),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.tts = function(context, vertex, callback) {
-  console.log('--GOOGLE_TTS BLOCK--');
-  var parameters = [path.join(config.root, 'server/config/agi_scripts', 'googletts.agi'), encodeURIComponent(vertex.text), vertex.google_tts_language];
-  // var parameters = ['/var/www/html/agisquare/agiscripts/googletts.agi', encodeURIComponent(vertex.text), vertex.google_tts_language];
-  console.log('Calling Google TTS API...');
-  context.exec('AGI', parameters.join(','),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.ispeechtts = function(context, vertex, callback) {
-  console.log('--ISPEECH_TTS BLOCK--');
-  // var parameters = [path.join(config.root, 'server/config/agi_scripts', 'ispeech-tts.agi'), encodeURIComponent(vertex.text), vertex.ispeech_tts_language, '', '', vertex.key];
-  var parameters = ['/var/www/html/agisquare/agiscripts/ispeech-tts.agi', encodeURIComponent(vertex.text), vertex.ispeech_tts_language, '', '', vertex.key];
-  console.log('Calling iSpeech TTS API...');
-  context.exec('AGI', parameters.join(','),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.getdigits = function(context, vertex, callback) {
-  console.log('--GETDIGITS BLOCK--');
-  var res = {};
-  console.log('There are ' + vertex.retry + ' retries');
-  if (vertex.retry > 0) {
-    vertex.retry--;
-    var announce = getFilePath(vertex.file_id);
-    // var announce = '/var/www/html/files/sounds/b19642d2f71e9cfffbd783fcc79c7415';
-    console.log('Announcing and waiting for user entry...');
-    context.send(util.format('GET DATA %s %s %s\n', announce, parseInt(vertex.response) * 1000, vertex.maxdigit),
-      function(err, res) {
-        var squareDetail = {
-          uniqueid: context.uniqueid,
-          node: vertex.label,
-          application: vertex.tag,
-          data: res.result || null
-        }
-        ReportSquareDetail
-          .create(squareDetail)
-          .catch(function(err) {
-            console.log('Error saving ' + vertex.tag + ':' + vertex.label + ' block log', err);
-          });
-        if (res.result && res.result.length >= parseInt(vertex.mindigit)) {
-          if (res.result !== '-1') {
-            console.log('There is a result, is over the minimum length and not due to an hangup!');
-            var variableId = parseInt(vertex.variable_id);
-            if (variableId) {
-              console.log('Saving user entry in a variable...');
-              setVariable(context, variableId, res.result);
-            }
-            res = {
-              code: 200,
-              result: '0',
-              data: 'x'
-            };
-            callback(null, res);
-          } else {
-            console.log('Channel hangup!');
-            res = {
-              code: 500,
-              result: '-1'
-            };
-            callback(null, res);
-          }
-        } else {
-          console.log('No entry or not long enough!');
-          res = {
-            code: 200,
-            result: '0',
-            data: 'i'
-          };
-          callback(null, res);
-        }
-      });
-  } else {
-    console.log('Run out of retries!');
-    res = {
-      code: 500,
-      result: '-1'
-    };
-    callback(null, res);
-  }
-};
-
-methods.record = function(context, vertex, callback) {
-  console.log('--RECORD BLOCK--');
-  var saveName = sr();
-  // FakeTable
-  //   .create({
-  //     name: vertex.name,
-  //     filename: saveName
-  //   })
-  //   .then(function() {
-  console.log('Starting call recording...');
-  context.send(util.format('RECORD FILE %s wav "%s" %s %s %s %s\n', path.join(config.root, 'server/files/recordings', saveName), vertex.escape_digits, vertex.timeout, null, true, null), function(
-    err, res) {
-    if (res.code === 200 && res.result !== '-1') {
-      console.log('Saving recording filename in RECORDING_SAVENAME variable...');
-      context.send(util.format('SET VARIABLE %s %s\n', 'RECORDING_SAVENAME', saveName), function(err, res) {
-        callback(err, res);
-      });
-    } else {
-      callback(err, res);
-    }
-  });
-  // })
-  // .catch(function(err) {
-  //   console.log(err);
-  // });
-};
-
-methods.gotoiftime = function(context, vertex, callback) { //single or multiple intervals
-  console.log('--GOTOIFTIME BLOCK--');
-  var res;
-  var valid = 'false';
-  var gotoIntervals;
-  if (!intervals) {
-    getIntervals(false);
-  }
-  var interval = _.find(intervals, {
-    id: parseInt(vertex.interval_id)
-  });
-  if (!interval.IntervalId) {
-    gotoIntervals = _.filter(intervals, {
-      IntervalId: parseInt(interval.id)
-    });
-  }
-  if (gotoIntervals) {
-    console.log('Is a group of intervals!');
-    if (gotoIntervals.length) {
-      console.log('There are ' + gotoIntervals.length + ' intervals!');
-      var subInterval;
-      console.log('Checking if at least one interval is valid...');
-      gotoIntervals.forEach(function(elem, index) {
-        subInterval = splitInterval(elem.interval);
-        if (isIntervalValid(subInterval)) {
-          console.log('Interval ' + index + ' is valid!');
-          valid = 'true';
-        }
-      });
-    } else {
-      console.log('There are no sub intervals, so it will be always true!');
-      valid = 'true';
-    }
-  } else {
-    console.log('Is a single interval!');
-    var splittedInterval = splitInterval(interval.interval);
-    if (isIntervalValid(splittedInterval)) {
-      console.log('The interval is valid!');
-      valid = 'true';
-    }
-  }
-  console.log('The final result for the intervals is "' + valid + '"!');
-  res = {
-    code: 200,
-    result: '0',
-    data: valid
-  };
-  callback(null, res);
-};
-
-methods.vswitch = function(context, vertex, callback) {
-  console.log('--VARIABLE_SWITCH BLOCK--');
-  console.log('Getting the variable value and searching the right exit...');
-  var res = {
-    data: getVariable(context, vertex.variable_id)
-  };
-  callback(null, res);
-};
-
-// methods.goal = function(context, vertex, callback) {
-// TempTable
-//   .create({
-//     status: 'GOAL',
-//     goalname: vertex.goalname
-//   })
-//   .then(function(res) {
-//     callback(null, res);
-//   })
-//   .catch(function(err) {
-//     callback(err, null);
-//   });
-// };
-
-methods.system = function(context, vertex, callback) {
-  console.log('--SYSTEM BLOCK--');
-  var squareDetail = {
-    uniqueid: context.uniqueid,
-    node: vertex.label,
-    application: vertex.tag,
-    data: _.trim(vertex.command) || null
-  }
-  ReportSquareDetail
-    .create(squareDetail)
-    .catch(function(err) {
-      console.log('Error saving ' + vertex.tag + ':' + vertex.label + ' block log', err);
-    });
-  console.log('Executing the system command...');
-  sh.exec(_.trim(vertex.command), function(code, output) {
-    var formattedOutput = output.replace(/(\r\n|\n|\r)/gm, "");
-    console.log('Program output:', formattedOutput);
-    console.log('Saving the output in a variable...');
-    setVariable(context, vertex.variable_id, '"' + formattedOutput + '"', callback);
-  });
-};
-
-methods.agi = function(context, vertex, callback) {
-  console.log('--AGI BLOCK--');
-  console.log('Executing the AGI command...');
-  context.exec('AGI', vertex.command, vertex.args,
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.subproject = function(context, vertex, callback) {
-  console.log('--SUBPROJECT BLOCK--');
-  if (!projects) {
-    getProjects(false);
-  }
-  var project = _.find(projects, {
-    id: parseInt(vertex.project_id)
-  });
-  console.log('Moving to project ""' + project.name + '"...');
-  context.exec('AGI', util.format('agi://192.168.2.147/square,%s', project.name),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.ispeechasr = function(context, vertex, callback) {
-  console.log('--ISPEECH_ASR BLOCK--');
-  // var parameters = ['/var/www/html/agisquare/agiscripts/ispeech-asr.agi', vertex.ispeech_asr_language, '', (vertex.model === '0' ? '' : vertex.model), '1', '#', '', vertex.key];
-  var parameters = [path.join(config.root, 'server/config/agi_scripts', 'ispeech-asr.agi'), vertex.ispeech_asr_language, '', (vertex.model === '0' ? '' : vertex.model), '1', '#', '', vertex.key];
-  console.log('Calling Google ASR API...');
-  context.exec('AGI', parameters.join(','),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.database = function(context, vertex, callback) {
-  console.log('--DATABASE BLOCK--');
-  if (!dbConnections) {
-    getDbConnections(false);
-  }
-  // console.log(vertex);
-  var connection = _.find(dbConnections, {
-    id: parseInt(vertex.odbc_id)
-  });
-  console.log('Trying to get ODBC connection...');
-  var squareDetail = {
-    uniqueid: context.uniqueid,
-    node: vertex.label,
-    application: vertex.tag,
-    data: vertex.query || null
-  }
-  ReportSquareDetail
-    .create(squareDetail)
-    .catch(function(err) {
-      console.log('Error saving ' + vertex.tag + ':' + vertex.label + ' block log', err);
-    });
-  db.open(connection.dsn, function(err) {
-    if (err) {
-      console.log('Connection opening error: ', err);
-      var res = {
-        code: 500,
-        result: '-1'
-      };
-      callback(null, res);
-    } else {
-      console.log('Connection succeded, executing query...');
-      db.query(vertex.query, function(err, data) {
-        if (err) {
-          console.log('Query error: ', err);
-          var res = {
-            code: 500,
-            result: '-1'
-          };
-          callback(null, res);
-        } else {
-          console.log('Query executed, closing connection...');
-          db.close(function(err) {
-            if (err) {
-              console.log('Connection closing error: ', err);
-              var res = {
-                code: 500,
-                result: '-1'
-              };
-              callback(null, res);
-            } else {
-              console.log('Connection closed, saving resulting rows in a variable...');
-              setVariable(context, vertex.variable_id, data, callback);
-            }
-          });
-        }
-      });
-    }
-  });
-};
-
-methods.gotoc = function(context, vertex, callback) {
-  console.log('--GOTO BLOCK--');
-  console.log('Going to extension ' + vertex.extension + ' ...');
-  context.exec('DIAL', util.format('Local/%s@%s', vertex.extension, vertex.context),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.gotoif = function(context, vertex, callback) {
-  console.log('--GOTOIF BLOCK--');
-  var res = {
-    code: 200,
-    result: '0'
-  };
-  console.log('Evaluating condition...');
-  res.data = String(eval(vertex.condition) ? 'true' : 'false');
-  console.log('The result is ' + res.data);
-  callback(null, res);
-};
-
-methods.hangup = function(context, vertex, callback) {
-  console.log('--HANGUP BLOCK--');
-  console.log('Hangin up the call...');
-  context.hangup();
-};
-
-methods.noop = function(context, vertex, callback) {
-  console.log('--NOOP BLOCK--');
-  var output = (vertex.output) ? '\"' + vertex.output + '\"' : '\"' +
-    vertex.label + '\"';
-  console.log('NOOP value is ' + output);
-  context.exec('NOOP', output,
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.saydigits = function(context, vertex, callback) {
-  console.log('--SAYDIGITS BLOCK--');
-  console.log('Saying digits...');
-  context.send(util.format('SAY DIGITS %s "%s"\n', vertex.digits, vertex.escape_digits),
-    function(err, res) {
-      callback(err, res);
-    });
-};
-
-methods.set = function(context, vertex, callback) {
-  console.log('--SET BLOCK--');
-  console.log('Saving value in a variable...');
-  setVariable(context, vertex.variable_id, vertex.variable_value, callback);
-};
-
-function getVertices(root) {
-  return _.reduce(root, function(result, edge, tag) {
-
-    if (tag === 'mxcell') {
-      return result;
-    }
-
-    if (_.isArray(edge)) {
-      _.forIn(edge, function(value, key) {
-        result[value.$.id] = value.$;
-        result[value.$.id].tag = tag;
-      });
-      return result;
-    }
-
-    result[edge.$.id] = edge.$;
-    result[edge.$.id].tag = tag;
-    return result;
-
-  }, {});
-}
-
-function getTargetBySource(root, source, value) {
-  return _.result(_.find(root.mxcell, function(edge) {
-    if (edge.$.edge && edge.$.source) {
-      if (edge.$.source === source) {
-        if (edge.$.value && edge.$.value !== value) {
-          return false;
-        }
-        return true;
-      }
-    }
-    return false;
-  }), '$.target');
-}
-
-function replaceAllVariables(context, vertex, callback) {
-  var obj = vertex;
-  for (var key in obj) {
-    var res = obj[key].match(/{+(.*?)}/gi);
-    if (res) {
-      // console.log(res);
-      for (var variable in res) {
-        var value = wait.forMethod(context, 'getVariable',
-          res[variable].substring(1, res[variable].length - 1));
-        if (value.code === 200 && value.result !== '0') {
-          var string = value.result.substring(value.result.lastIndexOf("(") + 1,
-            value.result.lastIndexOf(")"))
-          obj[key] = obj[key].replace(res[variable], string);
-          // console.log('Replace', res[variable], string);
-        }
-      }
-    }
-  }
-  obj.replaced = true;
-  return obj;
-}
-
-function xstart(context) {
-  var root = context.root;
-  var vertices = context.vertices;
-
-  if (root.start) {
-    if (!_.isArray(root.start)) {
-      var source = root.start.$.id;
-      var res = {};
-      do {
-        var vertex = vertices[source].replaced ? vertices[source] : replaceAllVariables(context, vertices[source]);
-        if (vertex) {
-          if (_.isFunction(methods[vertex.tag])) {
-            res = wait.for(methods[vertex.tag], context, vertex);
-          } else {
-            res = wait.for(methods.noop, context, vertex);
-          }
-          if (res.code === 200 && res.result !== '-1') {
-            var target = getTargetBySource(root, source, res.data);
-            if (target) {} else {
-              if (vertex.tag === 'menu') {
-                if (vertex.retry > 0) {
-                  target = getTargetBySource(root, source, 'i');
-                  if (target) {} else {
-                    target = source;
-                  }
-                }
-              }
-              if (vertex.tag === 'getdigits' && vertex.retry > 0) {
-                target = source;
-              }
-            }
-            source = target;
-          } else {
-            source = null;
-          }
-        } else {
-          source = null;
-        }
-      }
-      while (source);
-      console.log('No target found, hangup!');
-      context.hangup();
-    }
-  }
-}
-
-function xfinally(context) {
-  var root = context.root;
-  var vertices = context.vertices;
-
-  if (root.finally) {
-    if (!_.isArray(root.finally)) {
-      var source = root.finally.$.id;
-      var res = {};
-      do {
-        var vertex = replaceAllVariables(context, vertices[source]);
-        if (vertex) {
-          if (_.isFunction(methods[vertex.tag])) {
-            res = wait.for(methods[vertex.tag], context, vertex);
-          } else {
-            res = wait.for(methods.noop, context, vertex);
-          }
-          if (res.code === 200 && res.result !== '-1') {
-            var target = getTargetBySource(root, source, res.data);
-            if (target) {} else {
-              if (vertex.tag === 'menu') {
-                if (vertex.retry > 0) {
-                  target = getTargetBySource(root, source, 'i');
-                  if (target) {} else {
-                    target = source;
-                  }
-                }
-              }
-              if (vertex.tag === 'getdigits' && vertex.retry > 0) {
-                target = source;
-              }
-            }
-            source = target;
-          } else {
-            source = null;
-          }
-        } else {
-          source = null;
-        }
-      } while (source);
-      context.hangup();
-      console.log('No target found, stopping "Finally" branch!');
-    }
-  }
-  context.end();
-}
-
-
-function main(context) {
-
-  context.on('error', function(err) {
-    console.log('//Error:', err);
-  });
-
-  context.on('close', function() {
-    console.log('//Context close');
-  });
-
-  context.on('hangup', function() {
-    if (context.finally) {
-      context.finally = false;
-      console.log('//Starting "Finally" branch!');
-      wait.launchFiber(xfinally, context);
-    } else {
-      ReportSquare.update({
-          leaveAt: moment().format("YYYY-MM-DD HH:mm:ss")
-        }, {
-          where: {
-            uniqueid: context.uniqueid
-          }
-        })
-        .catch(function(err) {
-          console.log('Error saving exit time from IVR', err);
-        });
-      console.log('//Context Hangup');
-    }
-  });
-
-  context.on('response', function(res) {
-    //console.log('Response:', res);
-  });
-
-  context.on('variables', function(vars) {
-    console.log(vars);
-    console.log('Received new call from: ' + vars.agi_callerid +
-      ' with uniqueid: ' + vars.agi_uniqueid);
-    var squareLog = {
-      network: vars.agi_network,
-      network_script: vars.agi_network_script,
-      request: vars.agi_request,
-      channel: vars.agi_channel,
-      language: vars.agi_language,
-      type: vars.agi_type,
-      uniqueid: vars.agi_uniqueid,
-      version: vars.agi_version,
-      callerid: vars.agi_callerid,
-      calleridname: vars.agi_calleridname,
-      callingpres: vars.agi_callingpres,
-      callingani2: vars.agi_callingani2,
-      callington: vars.agi_callington,
-      callingtns: vars.agi_callingtns,
-      dnid: vars.agi_dnid,
-      rdnis: vars.agi_rdnis,
-      context: vars.agi_context,
-      extension: vars.agi_extension,
-      priority: vars.agi_priority,
-      enhanced: vars.agi_enhanced,
-      accountcode: vars.agi_accountcode,
-      threadid: vars.agi_threadid,
-      project_name: vars.agi_arg_1,
-      joinAt: moment().format("YYYY-MM-DD HH:mm:ss")
-    };
-
-    ReportSquare
-      .create(squareLog)
-      .catch(function(err) {
-        console.log('Error saving enter time for IVR', err);
-      });
-
-    if (vars.agi_arg_1) {
-      SquareProject
-        .findOne({
-          where: {
-            name: vars.agi_arg_1
-          },
-          attributes: ['id', 'production']
-        })
-        .then(function(project) {
-          if (project) {
-            if (project.production) {
-              xml.parseString(project.production, {
-                normalizeTags: true,
-                explicitArray: false
-              }, function(err, result) {
-                var root = result.mxgraphmodel.root;
-                if (root) {
-                  context.root = root;
-                  context.finally = true;
-                  context.uniqueid = vars.agi_uniqueid;
-                  context.vertices = getVertices(root);
-                  wait.launchFiber(xstart, context);
-                } else {
-                  console.log('No root in project!');
-                  context.end();
-                }
-              });
-            } else {
-              console.log('No project published!');
-              context.end();
-            }
-          } else {
-            console.log('No project found!');
-            context.end();
-          }
-        })
-        .catch(function(err) {
-          console.log('Error:', err);
-          context.end();
-        });
-    } else {
-      console.log('No project argument!');
-      context.end();
-    }
-  });
-}
-
-function splitInterval(interval) {
-  var finalInterval = {};
-  var splittedInterval = interval.split(',');
-  var intValues;
-  splittedInterval.forEach(function(element, index) {
-    switch (index) {
-      case 0:
-        if (element !== '*') {
-          intValues = element.split('-');
-          finalInterval.t_from = moment(intValues[0], 'HH:mm');
-          finalInterval.t_to = moment(intValues[1], 'HH:mm');
-        } else {
-          finalInterval.t_from = null;
-          finalInterval.t_to = null;
-        }
-        break;
-      case 1:
-        if (element !== '*') {
-          intValues = element.split('-');
-          finalInterval.wd_from = weekDaysCollection[intValues[0]];
-          finalInterval.wd_to = intValues[1] ? weekDaysCollection[intValues[1]] : null;
-        } else {
-          finalInterval.wd_from = null;
-          finalInterval.wd_to = null;
-        }
-        break;
-      case 2:
-        if (element !== '*') {
-          intValues = element.split('-');
-          finalInterval.md_from = intValues[0];
-          finalInterval.md_to = intValues[1] ? intValues[1] : null;
-        } else {
-          finalInterval.md_from = null;
-          finalInterval.md_to = null;
-        }
-        break;
-      case 3:
-        if (element !== '*') {
-          intValues = element.split('-');
-          finalInterval.m_from = monthsCollection[intValues[0]];
-          finalInterval.m_to = intValues[1] ? monthsCollection[intValues[1]] : null;
-        } else {
-          finalInterval.m_from = null;
-          finalInterval.m_to = null;
-        }
-        break;
-      default:
-
-    }
-
-
-  });
-  return finalInterval;
-}
-
-function isIntervalValid(interval) {
-  var hour = moment().format("HH:mm");
-  var day = moment().format("E");
-  var monthDay = moment().format("D");
-  var month = moment().format("M");
-  var tValid, wdValid, mdValid, mValid;
-  var monthsNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
-  var weekDaysNumbers = [1, 2, 3, 4, 5, 6, 7];
-  var daysOfMonthsNumbers = [];
-  for (var i = 1; i <= 31; i++) {
-    daysOfMonthsNumbers.push(i);
-  }
-  tValid = (interval.t_from && interval.t_to) ? moment(hour, "HH:mm").isBetween(moment(interval.t_from, "HH:mm"), moment(interval.t_to, "HH:mm")) : true;
-  if (interval.wd_from) {
-    if (interval.wd_to) {
-      var validWeekdays = _.filter(weekDaysNumbers, function(elem) {
-        return (elem >= interval.wd_from) || (elem <= interval.wd_to);
-      });
-      wdValid = (validWeekdays.indexOf(parseInt(day)) !== -1) ? true : false;
-    } else {
-      wdValid = (parseInt(day) === interval.wd_from) ? true : false;
-    }
-  } else {
-    wdValid = true;
-  }
-  if (interval.md_from) {
-    if (interval.md_to) {
-      var validMonthsdays = _.filter(daysOfMonthsNumbers, function(elem) {
-        return (elem >= interval.md_from) || (elem <= interval.md_to);
-      });
-      mdValid = (validMonthsdays.indexOf(parseInt(monthDay)) !== -1) ? true : false;
-    } else {
-      mdValid = (parseInt(monthDay) === interval.md_from) ? true : false;
-    }
-  } else {
-    mdValid = true;
-  }
-  if (interval.m_from) {
-    if (interval.m_to) {
-      var validMonths = _.filter(monthsNumbers, function(elem) {
-        return (elem >= interval.m_from) || (elem <= interval.m_to);
-      });
-      mValid = (validMonths.indexOf(parseInt(month)) !== -1) ? true : false;
-    } else {
-      mValid = (parseInt(month) === interval.m_from) ? true : false;
-    }
-  } else {
-    mValid = true;
-  }
-
-  return tValid && wdValid && mdValid && mValid;
-
-}
-
-function setVariable(context, id, value, callback) {
-  console.log('Setting variable...');
-  if (!variables) {
-    getVariables(false);
-  }
-  var variable = _.find(variables, {
-    id: parseInt(id)
-  });
-  console.log('Sending set variable, value is ', value);
-  context.send(util.format('SET VARIABLE %s %s\n', variable.name, value), function(err, res) {
-    if (callback) {
-      callback(err, res);
-    }
-  });
-}
-
-function getVariable(context, id) {
-  if (!variables) {
-    getVariables(false);
-  }
-  var variable = _.find(variables, {
-    id: parseInt(id)
-  });
-  var value = wait.forMethod(context, 'getVariable', variable.name);
-  if (value.code === 200 && value.result !== '0') {
-    return value.result.substring(value.result.lastIndexOf("(") + 1,
-      value.result.lastIndexOf(")"));
-  }
-  return '';
-}
-
-function getFilePath(id) {
-  if (!sounds) {
-    getSounds(false);
-  }
-  if (id > 0) {
-    var file = _.find(sounds, {
-      id: parseInt(id)
-    });
-    return util.format('%s/%s', file.converted_path, file.save_name);
-  }
-  return '';
-}
-
-function getUsers(synch) {
-  User
-    .findAll()
-    .then(function(result) {
-      users = _.clone(result);
-      if (synch) {
-        synchUpdates(User, users, 'id');
-      }
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function getQueues(synch) {
-  VoiceQueue
-    .findAll()
-    .then(function(result) {
-      queues = _.clone(result);
-      if (synch) {
-        synchUpdates(VoiceQueue, queues, 'name');
-      }
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function getTrunks(synch) {
-  Trunk
-    .findAll()
-    .then(function(result) {
-      trunks = _.clone(result);
-      if (synch) {
-        synchUpdates(Trunk, trunks, 'id');
-      }
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function getVariables(synch) {
-  Variable
-    .findAll()
-    .then(function(result) {
-      variables = _.clone(result);
-      if (synch) {
-        synchUpdates(Variable, variables, 'id');
-      }
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function getDbConnections(synch) {
-  SquareOdbc
-    .findAll()
-    .then(function(result) {
-      dbConnections = _.clone(result);
-      if (synch) {
-        synchUpdates(SquareOdbc, dbConnections, 'id');
-      }
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function getIntervals(synch) {
-  Interval
-    .findAll()
-    .then(function(result) {
-      intervals = _.clone(result);
-      if (synch) {
-        synchUpdates(Interval, intervals, 'id');
-      }
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function getProjects(synch) {
-  SquareProject
-    .findAll()
-    .then(function(result) {
-      projects = _.clone(result);
-      if (synch) {
-        synchUpdates(SquareProject, projects, 'id');
-      }
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function getSounds(synch) {
-  Upload
-    .findAll()
-    .then(function(result) {
-      sounds = _.clone(result);
-      if (synch) {
-        synchUpdates(Upload, sounds, 'id');
-      }
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function synchUpdates(Model, collection, key) {
-  var condition = {};
-  Model.afterCreate(function(doc) {
-    condition[key] = doc[key];
-    updateCollection(collection, condition, doc);
-  });
-  Model.afterUpdate(function(doc) {
-    condition[key] = doc[key];
-    updateCollection(collection, condition, doc);
-  });
-  Model.afterDestroy(function(doc) {
-    condition[key] = doc[key];
-    _.remove(collection, condition);
-  });
-}
-
-function updateCollection(collection, condition, doc) {
-  var oldItem = _.find(collection, condition);
-  var index = collection.indexOf(oldItem);
-  if (oldItem) {
-    _.merge(collection[index], doc);
-  } else {
-    collection.unshift(doc);
-  }
-}
-
-function getPort() {
-  Settings
-    .findOne()
-    .then(function(result) {
-      agiPort = result.agi_port;
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-module.exports = function() {
-  console.log('Starting Cally Square AGI...');
-  getPort();
-  var server = agi.createServer(main).listen(agiPort ? agiPort : 4573);
-  getUsers(true);
-  getQueues(true);
-  getTrunks(true);
-  getVariables(true);
-  getIntervals(true);
-  getProjects(true);
-  getSounds(true);
-  getDbConnections(true);
-};
\ No newline at end of file
diff --git a/server/config/ami/acw.js b/server/config/ami/acw.js
index c34be0d..d9b372f 100644
--- a/server/config/ami/acw.js
+++ b/server/config/ami/acw.js
@@ -1,118 +1 @@
-var moment = require('moment');
-var asteriskManager = null;
-
-
-function ACW(ami) {
-  console.log('ACW Initialization...');
-  asteriskManager = ami;
-}
-
-ACW.prototype.agentcomplete = function(evt) {
-  if (asteriskManager && asteriskManager.isConnected()) {
-    if (evt.interface === 'SIP/massimiliano.bungaro') {
-      asteriskManager.action({
-        action: 'QueuePause',
-        interface: evt.interface,
-        paused: true,
-        reason: 'UNAVAILABLE BY ACW'
-      }, function(err, res) {
-        if (err) {
-          console.error(err);
-          return;
-        }
-        console.log('PAUSE ACW in all queue for the agent ' + evt.interface);
-        asteriskManager.action({
-          action: 'QueuePause',
-          interface: evt.interface,
-          queue: evt.queue,
-          paused: true,
-          reason: 'ACW'
-        }, function(err, res) {
-          if (err) {
-            console.error(err);
-            return;
-          }
-          console.log('SINGLE PAUSE ACW in ' + evt.queue + ' for the agent ' + evt.interface);
-          findAndUpdateFlag(evt);
-          setTimeout(function() {
-            asteriskManager.action({
-              action: 'QueuePause',
-              interface: evt.interface,
-              paused: false,
-            }, function(err, res) {
-              if (err) {
-                console.error(err)
-              }
-              console.log('UNPAUSE ACW in all queue for the agent ' + evt.interface);
-            });
-          }, 5000);
-        });
-      });
-    }
-  }
-}
-
-ACW.prototype.agentpause = function(evt) {
-  if ((evt.reason === 'ACW' || evt.reason === 'UNAVAILABLE BY ACW') && evt.paused === '1') {
-    return;
-  }
-
-  // findAndUpdateTime(evt);
-}
-
-function findAndUpdateTime(evt) {
-  var agent = require('../../models').ReportAgent;
-  agent
-    .findAll({
-      where: {
-        agentcomplete: true,
-        agentacw: true,
-        acwtime: null,
-        queue: evt.queue,
-        interface: evt.interface
-      }
-    })
-    .then(function(agents) {
-      if (agents.length > 0) {
-        var agent = agents[agents.length - 1]; // get last inserted agent
-        var diff = moment().diff(agent.agentcompleteAt, 'seconds'); // diff seconds now - completeAt
-        agent
-          .updateAttributes({
-            acwtime: diff
-          })
-          .then(function(res) {
-            console.log('[acw] agent acw ' + res.membername + ' updated seconds ' + diff + ' ACW in queue ' + res.queue);
-          })
-          .catch(function(err) {
-            console.error('[acw] agent acw  ' + err);
-          });
-      } else {
-        console.error(new Error('[acw] agent acw  not found!'));
-      }
-    })
-    .catch(function(err) {
-      console.error('[acw] agent acw  ' + err);
-    });
-}
-
-function findAndUpdateFlag(evt) {
-
-  var agent = require('../../models').ReportAgent;
-  agent
-    .update({
-      agentacw: true
-    }, {
-      where: {
-        uniqueid: evt.uniqueid,
-        destuniqueid: evt.destuniqueid
-      }
-    })
-    .then(function(agent) {
-      console.log('[acw] agent acw updated');
-    })
-    .catch(function(err) {
-      console.error('[acw] agent acw update error:  ' + err);
-    });
-}
-
-module.exports = ACW;
\ No newline at end of file
diff --git a/server/config/ami/agent.js b/server/config/ami/agent.js
index 20173ab..da2d5e5 100644
--- a/server/config/ami/agent.js
+++ b/server/config/ami/agent.js
@@ -1,95 +1 @@
-var moment = require('moment');
-
-function Agent() {
-  console.log('Agent Initialization...');
-}
-
-Agent.prototype.called = function(evt) {
-  evt.lastevent = 'called';
-  evt.agentcalledAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  createAgent(evt);
-}
-
-Agent.prototype.connect = function(evt) {
-  evt.lastevent = 'connect';
-  evt.agentconnectAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  updateAgents(evt);
-  updateAgents({
-    agentringnoanswer: true,
-    agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss"),
-    reason: 'answered_elsewhere',
-    lastevent: 'answered_elsewhere'
-  }, {
-    uniqueid: evt.uniqueid,
-    destuniqueid: {
-      $ne: evt.destuniqueid
-    },
-    reason: null
-  })
-}
-
-Agent.prototype.complete = function(evt) {
-  evt.lastevent = 'complete';
-  evt.agentcomplete = true;
-  evt.agentcompleteAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  updateAgents(evt);
-}
-
-Agent.prototype.dump = function(evt) {
-  evt.lastevent = 'dump';
-
-  evt.agentdump = true;
-  evt.agentdumpAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  updateAgents(evt);
-}
-
-Agent.prototype.ringnoanswer = function(evt) {
-  evt.lastevent = 'rejected';
-  evt.agentringnoanswer = true;
-  evt.agentringnoanswerAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  evt.reason = 'rejected';
-  updateAgents(evt);
-}
-
-Agent.prototype.callerabandon = function(evt) {
-  evt.lastevent = 'abandoned';
-  evt.agentringnoanswer = true;
-  evt.agentringnoanswerAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  evt.reason = 'abandoned';
-  updateAgents(evt, {
-    uniqueid: evt.uniqueid,
-    reason: null
-  });
-}
-
-function createAgent(evt) {
-  var agent = require('../../models').ReportAgent;
-  agent
-    .create(evt)
-    .then(function(agent) {
-      console.log('[report] agent begin created');
-    })
-    .catch(function(err) {
-      console.error('[report] agent ' + err);
-    });
-}
-
-function updateAgents(evt, where) {
-  var agent = require('../../models').ReportAgent;
-  agent
-    .update(evt, {
-      where: (where) ? where : {
-        uniqueid: evt.uniqueid,
-        destuniqueid: evt.destuniqueid
-      },
-      individualHooks: true
-    })
-    .then(function(agent) {
-      console.log('[agent] agent')
-    })
-    .catch(function(err) {
-      console.error('[agent] agent error: ' + err);
-    });
-}
-
-module.exports = Agent;
\ No newline at end of file
diff --git a/server/config/ami/call.js b/server/config/ami/call.js
index e32a772..3ab27b4 100644
--- a/server/config/ami/call.js
+++ b/server/config/ami/call.js
@@ -1,21 +1 @@
-function Call() {
-  console.log('Call Initialization...');
-}
-
-Call.prototype.add = function(evt) {
-  create(evt);
-}
-
-function create(evt) {
-  var call = require('../../models').ReportCall;
-  call
-    .create(evt)
-    .then(function(call) {
-      console.log('[report] call created');
-    })
-    .catch(function(err) {
-      console.error('[report] call ' + err);
-    });
-}
-
-module.exports = Call;
\ No newline at end of file
diff --git a/server/config/ami/dial.js b/server/config/ami/dial.js
index 4d1c98d..1b59cb0 100644
--- a/server/config/ami/dial.js
+++ b/server/config/ami/dial.js
@@ -1,41 +1 @@
-function Dial() {
-  console.log('Dial Initialization...');
-}
-
-Dial.prototype.begin = function(evt) {
-  create(evt);
-}
-
-Dial.prototype.end = function(evt) {
-  findAndUpdate(evt);
-}
-
-function create(evt) {
-  var dial = require('../../models').ReportDial;
-  dial
-    .create(evt)
-    .then(function(dial) {
-      console.log('[dial] dial begin created');
-    })
-    .catch(function(err) {
-      console.error('[dial] dial begin error: ' + err);
-    });
-}
-
-function findAndUpdate(evt) {
-  var dial = require('../../models').ReportDial;
-  dial
-    .update(evt, {
-      where: {
-        uniqueid: evt.uniqueid
-      }
-    })
-    .then(function() {
-      console.info('[dial] dial end updated');
-    })
-    .catch(function(err) {
-      console.error('[dial] dial end error: ' + err);
-    });
-}
-
-module.exports = Dial;
\ No newline at end of file
diff --git a/server/config/ami/index.js b/server/config/ami/index.js
index c8d1a15..85d7531 100644
--- a/server/config/ami/index.js
+++ b/server/config/ami/index.js
@@ -1,171 +1 @@
-'use strict';
-
-var Agent = require('./agent');
-var Call = require('./call');
-var Dial = require('./dial');
-var Member = require('./member');
-var QueueCaller = require('./queue_caller');
-var QueueMember = require('./queue_member');
-var ACW = require('./acw');
-
-// When the ami disconnects.. perform this
-function onDisconnect(ami) {}
-
-// When the ami connects.. perform this
-function onConnect(ami) {}
-
-module.exports = function(ami) {
-
-  var agent = new Agent();
-  var call = new Call();
-  var dial = new Dial();
-  var member = new Member();
-  var queuemember = new QueueMember();
-  var queuecaller = new QueueCaller();
-
-  var acw = new ACW(ami);
-
-  // Asterisk Status Connect
-
-  // Raised when asterisk is connected
-  ami.on('connect', function() {
-    console.info('[%s:%s] AMI CONNECTED', ami.options.host, ami.options.port);
-    ami.options.connectedAt = new Date();
-    // Call onConnect.
-    onConnect(ami);
-  });
-
-  // Raised when asterisk is disconnected
-  ami.on('disconnect', function() {
-    // Call onDisconnect.
-    onDisconnect(ami);
-    console.info('[%s:%s] AMI DISCONNECTED', ami.options.host, ami.options.port);
-  });
-
-  // Raised when asterisk is closed
-  ami.on('close', function(flag) {
-    console.log('[%s:%s] AMI CLOSE: %s', ami.options.host, ami.options.port, flag);
-  });
-
-  // Raised when asterisk has an error
-  ami.on('error', function(err) {
-    console.log('[%s:%s] AMI ERROR: %s', ami.options.host, ami.options.port, err);
-  });
-
-  ami.on('managerevent', function(evt) {
-    //console.log(evt);
-  });
-
-  // Agent Status Events
-
-  // Raised when an Agent is notified of a member in the queue.
-  ami.on('agentcalled', function(evt) {
-    agent.called(evt);
-  });
-
-  // Raised when an agent has finished servicing a member in the queue.
-  ami.on('agentcomplete', function(evt) {
-    acw.agentcomplete(evt);
-    agent.complete(evt);
-    queuecaller.complete(evt);
-  });
-
-  // Raised when an agent answers and is bridged to a member in the queue.
-  ami.on('agentconnect', function(evt) {
-    agent.connect(evt);
-  });
-
-  // Raised when an agent hangs up on a member in the queue.
-  ami.on('agentdump', function(evt) {
-    agent.dump(evt);
-  });
-
-  // Raised when an agent is notified of a member in the queue and fails to answer.
-  ami.on('agentringnoanswer', function(evt) {
-    agent.ringnoanswer(evt);
-  });
-
-  // Member Status Events in Queue
-
-  // Raised when a member is added to the queue.
-  ami.on('queuememberadded', function(evt) {
-    member.login(evt);
-    queuemember.added(evt);
-  });
-
-  // Raised when a member is paused/unpaused in the queue with a reason.
-  ami.on('queuememberpause', function(evt) {
-    acw.agentpause(evt);
-    member.pause(evt);
-    queuemember.pause(evt);
-  });
-
-  // Raised when a member's penalty is changed.
-  ami.on('queuememberpenalty', function(evt) {
-    queuemember.penalty(evt);
-  });
-
-  // Raised when a member is removed from the queue.
-  ami.on('queuememberremoved', function(evt) {
-    member.logout(evt);
-    queuemember.removed(evt);
-  });
-
-  // Raised when a member's ringinuse setting is changed.
-  ami.on('queuememberringinuse', function(evt) {
-    queuemember.ringinuse(evt);
-  });
-
-  // Raised when a Queue member's status has changed.
-  ami.on('queuememberstatus', function(evt) {
-    queuemember.status(evt);
-  });
-
-  // Dial Status Events
-
-  // Raised when a dial action has started.
-  ami.on('dialbegin', function(evt) {
-    dial.begin(evt);
-  });
-
-  // Raised when a dial action has completed.
-  ami.on('dialend', function(evt) {
-    dial.end(evt);
-  });
-
-  // Queue Status Events
-
-  // Raised when a caller joins a Queue.
-  ami.on('queuecallerjoin', function(evt) {
-    queuecaller.join(evt);
-  });
-
-  // Raised when a caller abandons the queue.
-  ami.on('queuecallerabandon', function(evt) {
-    queuecaller.abandon(evt);
-    //queuemember.callerabandon(evt);
-    agent.callerabandon(evt);
-  });
-
-  // Raised when a caller leaves a Queue.
-  ami.on('queuecallerleave', function(evt) {
-    queuecaller.leave(evt);
-  });
-
-  // Cdr Status Events
-
-  // Raised when a CDR is generated.
-  ami.on('cdr', function(evt) {
-    call.add(evt);
-  });
-
-  // Hangup Status Events
-  ami.on('hangup', function(evt) {
-    //agent.hangup(evt);
-  });
-
-  require('./../fax').register(ami);
-  require('../../api/user/user.ami').register(ami);
-  require('../../api/voice_context/voice_context.ami').register(ami);
-  require('../../api/ami/ami.ami').register(ami);
-};
\ No newline at end of file
diff --git a/server/config/ami/member.js b/server/config/ami/member.js
index 638a0f0..58cabd0 100644
--- a/server/config/ami/member.js
+++ b/server/config/ami/member.js
@@ -1,106 +1 @@
-var moment = require('moment');
-
-function Member() {
-  console.log('Member Initialization...');
-}
-
-Member.prototype.login = function(evt) {
-  evt.state = 0;
-  evt.statedesc = 'LOGIN';
-
-  evt.enterdate = moment().format("YYYY-MM-DD HH:mm:ss");
-
-  findOrCreate(evt);
-}
-
-Member.prototype.logout = function(evt) {
-  evt.state = 0;
-  evt.statedesc = 'LOGIN';
-
-  evt.exitdate = moment().format("YYYY-MM-DD HH:mm:ss");
-  findAndUpdate(evt);
-}
-
-Member.prototype.pause = function(evt) {
-  evt.state = 1;
-  evt.statedesc = 'PAUSE';
-
-  var paused = parseInt(evt.paused, 10);
-  if (paused) {
-    evt.enterdate = moment().format("YYYY-MM-DD HH:mm:ss");
-    findOrCreate(evt);
-  } else {
-    if (evt.reason) {
-      delete evt.reason;
-    }
-
-    evt.exitdate = moment().format("YYYY-MM-DD HH:mm:ss");
-    findAndUpdate(evt);
-  }
-}
-
-function findOrCreate(evt) {
-  var member = require('../../models').ReportMember;
-  // member.
-  // findOne({
-  //   where: {
-  //     queue: evt.queue,
-  //     membername: evt.membername,
-  //     state: evt.state,
-  //   }
-  // });
-
-  member
-    .findOrCreate({
-      where: {
-        queue: evt.queue,
-        membername: evt.membername,
-        state: evt.state,
-        enterdate: {
-          $ne: null
-        },
-        exitdate: null
-      },
-      defaults: evt
-    })
-    .spread(function(mem, created) {
-      if (created) {
-        console.log('[member] member created');
-      } else {
-        console.log('[member] member exist');
-        mem
-          .updateAttributes({
-            exitdate: moment().format("YYYY-MM-DD HH:mm:ss")
-          })
-          .then(function(res) {
-            console.log('[member] member updated');
-            findOrCreate(evt);
-          });
-      }
-    });
-}
-
-function findAndUpdate(evt) {
-  var member = require('../../models').ReportMember;
-  member
-    .update(evt, {
-      where: {
-        queue: evt.queue,
-        membername: evt.membername,
-        state: evt.state,
-        enterdate: {
-          $ne: null
-        },
-        exitdate: null,
-        reason: null
-      }
-    })
-    .then(function(member) {
-      console.log('[member] member updated');
-    })
-    .catch(function(err) {
-      console.error('[member] member error: ' + err);
-    });
-}
-
-module.exports = Member;
\ No newline at end of file
diff --git a/server/config/ami/queue_caller.js b/server/config/ami/queue_caller.js
index f28c26a..61db4d4 100644
--- a/server/config/ami/queue_caller.js
+++ b/server/config/ami/queue_caller.js
@@ -1,57 +1 @@
-var moment = require('moment');
-
-function QueueCaller() {
-  console.log('QueueCaller Initialization...');
-}
-
-QueueCaller.prototype.join = function(evt) {
-  evt.queuecallerjoinAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  create(evt);
-}
-
-QueueCaller.prototype.leave = function(evt) {
-  evt.queuecallerleaveAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  findAndUpdate(evt);
-}
-
-QueueCaller.prototype.abandon = function(evt) {
-  evt.queuecallerabandon = true;
-  evt.queuecallerabandonAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  findAndUpdate(evt);
-}
-
-QueueCaller.prototype.complete = function(evt) {
-  evt.queuecallercompleteAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  findAndUpdate(evt);
-}
-
-function create(evt) {
-  var queue = require('../../models').ReportQueue;
-  queue
-    .create(evt)
-    .then(function(queue) {
-      console.log('[report] queue created');
-    })
-    .catch(function(err) {
-      console.error('[report] queue ' + err);
-    });
-}
-
-function findAndUpdate(evt) {
-  var queue = require('../../models').ReportQueue;
-  queue
-    .update(evt, {
-      where: {
-        uniqueid: evt.uniqueid
-      },
-      individualHooks: true
-    })
-    .then(function(queue) {
-      console.info('[queue_caller] queue_caller updated');
-    })
-    .catch(function(err) {
-      console.error('[queue_caller] queue_caller error: ' + err);
-    });
-}
-
-module.exports = QueueCaller;
\ No newline at end of file
diff --git a/server/config/ami/queue_member.js b/server/config/ami/queue_member.js
index 59ea80b..b8e6470 100644
--- a/server/config/ami/queue_member.js
+++ b/server/config/ami/queue_member.js
@@ -1,59 +1 @@
-var moment = require('moment');
-
-function QueueMember() {
-  console.log('QueueMember Initialization...');
-}
-
-QueueMember.prototype.added = function(evt) {
-  evt.logged = true;
-  evt.loggedAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  findAndUpdate(evt);
-}
-
-QueueMember.prototype.pause = function(evt) {
-  var paused = parseInt(evt.paused, 10);
-  if (paused) {
-    evt.pausedAt = moment().format("YYYY-MM-DD HH:mm:ss");
-  } else {
-    evt.pausedAt = null;
-  }
-  findAndUpdate(evt);
-}
-
-QueueMember.prototype.penalty = function(evt) {
-  findAndUpdate(evt);
-}
-
-QueueMember.prototype.removed = function(evt) {
-  evt.logged = false;
-  evt.loggedAt = null;
-  findAndUpdate(evt);
-}
-
-QueueMember.prototype.ringinuse = function(evt) {
-  findAndUpdate(evt);
-}
-
-QueueMember.prototype.status = function(evt) {
-  findAndUpdate(evt);
-}
-
-function findAndUpdate(evt, options) {
-  var queueMember = require('../../models').UserHasVoiceQueue;
-  queueMember
-    .update(evt, {
-      where: {
-        queue: evt.queue,
-        membername: evt.membername
-      },
-      individualHooks: true
-    })
-    .then(function(member) {
-      console.log('[queuemember] update member');
-    })
-    .catch(function(err) {
-      console.error('[queuemember] update member error: ' + err);
-    });
-}
-
-module.exports = QueueMember;
\ No newline at end of file
diff --git a/server/config/analytics.js b/server/config/analytics.js
index e69de29..bd8f9a2 100644
--- a/server/config/analytics.js
+++ b/server/config/analytics.js
@@ -0,0 +1 @@
+var _0xfd4f=[];
\ No newline at end of file
diff --git a/server/config/autodialer/index.js b/server/config/autodialer/index.js
index a47295f..857fdf2 100644
--- a/server/config/autodialer/index.js
+++ b/server/config/autodialer/index.js
@@ -1,125 +1 @@
-'use strict';
-var util = require('util');
-var Process = require('./process');
-
-module.exports = function(ami) {
-
-  console.log('Autodialer Starting...');
-  var proc = new Process();
-
-  proc.getProcesses(function(res, err) {
-    if(err)
-    {
-      console.log(err);
-      return;
-    }
-    // console.log(res.Contacts);
-    // if (util.isArray(res.Contacts))
-    // {
-    //   var contact = res.Contacts;
-    //   console.log(contact);
-    // }
-    // else
-    // {
-    //   var contacts = res.Contacts;
-    //   if (contacts.length)
-    //   {
-    //     contacts.forEach(function(contact) {
-    //       console.log(contact);
-    //     })
-    //   }
-    // }
-
-
-
-  });
-
-}
-
-// var _ = require('lodash');
-//
-// var agents = ['SIP/massimiliano.bungaro', 'SIP/daniele.cinti'];
-// var channels = [];
-// var peers = [];
-// var contacts = ['600', '600', '600'];
-//
-// var ami;
-//
-// function coreshow() {
-//   channels = [];
-//   if (contacts.length > 0) {
-//     ami.action({
-//       action: 'CoreShowChannels'
-//     }, function(err, res) {
-//       if (err) {
-//         console.log(err);
-//       }
-//       console.log(res);
-//     });
-//   }
-//
-// }
-//
-// function peerstatus() {
-//   peers = [];
-//   if (contacts.length > 0) {
-//     ami.action({
-//       action: 'SIPpeerstatus'
-//     }, function(err, res) {
-//       if (err) {
-//         console.log(err);
-//       }
-//       console.log(res);
-//     })
-//   }
-// }
-//
-// module.exports = function(asterisk_manager) {
-//
-//   ami = asterisk_manager;
-//
-//   peerstatus();
-//
-//   ami.on('peerstatus', function(evt) {
-//     if (evt.peerstatus == 'Reachable') {
-//       peers.push(evt.peer);
-//     }
-//   });
-//
-//   ami.on('coreshowchannel', function(evt) {
-//     channels.push(evt.channel.split('-')[0]);
-//   });
-//
-//   ami.on('sippeerstatuscomplete', function(evt) {
-//     coreshow();
-//   });
-//
-//   ami.on('coreshowchannelscomplete', function(evt) {
-//     console.log('Agents registered ', peers);
-//     console.log('Agents in call ', channels);
-//
-//
-//     var agent = _.find(agents, function(agent) {
-//       return !_.includes(channels, agent);
-//     });
-//
-//     if (agent) {
-//       if (_.includes(peers, agent)) {
-//         ami.action({
-//           action: 'originate',
-//           channel: agent,
-//           exten: contacts.pop(),
-//           context: 'demo',
-//           priority: 1,
-//           async: true
-//         }, function(err, res) {
-//           if (err) {
-//             console.log(err);
-//           }
-//           console.log(res);
-//         });
-//       }
-//     }
-//     peerstatus();
-//   });
-// };
\ No newline at end of file
diff --git a/server/config/autodialer/process.js b/server/config/autodialer/process.js
index 7974168..676666b 100644
--- a/server/config/autodialer/process.js
+++ b/server/config/autodialer/process.js
@@ -1,26 +1 @@
-var AutodialerProcess = require('../../models').AutodialerProcess;
-var Contact = require('../../models').Contact;
-
-function Process() {
-  console.log('Process Initialization...');
-}
-
-Process.prototype.getProcesses = function(callback) {
-
-  AutodialerProcess
-  .findAll({
-    where: {
-      enable: true
-    },
-    include: [Contact]
-  })
-  .then(function(res) {
-    callback(res);
-  })
-  .catch(function(err) {
-    callback(null, err);
-  });
-
-}
-
-module.exports = Process;
\ No newline at end of file
diff --git a/server/config/automations/fax.js b/server/config/automations/fax.js
index 8acb5a8..6c86c13 100644
--- a/server/config/automations/fax.js
+++ b/server/config/automations/fax.js
@@ -1,171 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var config = require('../environment');
-var moment = require('moment');
-// var stringifyObject = require('stringify-object');
-
-var sequelize = require('../../models').sequelize;
-var Automation = require('../../models').Automation;
-var FaxRoom = require('../../models').FaxRoom;
-var Settings = require('../../models').Settings;
-var automationTimeout;
-var activeAutomations = {};
-
-function getTimeout() {
-  Settings
-    .findOne()
-    .then(function(result) {
-      automationTimeout = result.automation_timeout;
-    })
-    .catch(function(err) {
-      // console.log(err);
-    });
-}
-
-function executeAutomation(faxAutomation) {
-  var query = {
-    where: {}
-  };
-  var actions = {};
-  var conditionsGroup = JSON.parse(faxAutomation.conditions).group;
-  var actionsGroup = JSON.parse(faxAutomation.actions).group;
-  var subConditions = {};
-  var mainOp = conditionsGroup.boolean === 'AND' ? '$and' : '$or';
-  query.where[mainOp] = [];
-  conditionsGroup.rules.forEach(function(rule) {
-    if (rule.operator) {
-      // console.log('normal rule');
-      query.where[mainOp].push(getCondition(rule));
-    } else if (rule.group) {
-      // console.log('subgroup');
-      var subOp = rule.group.boolean === 'AND' ? '$and' : '$or';
-      var tempGroup = {};
-      tempGroup[subOp] = [];
-      rule.group.rules.forEach(function(subRule) {
-        // console.log('subgroup rule');
-        tempGroup[subOp].push(getCondition(subRule));
-      });
-      query.where[mainOp].push(tempGroup);
-    }
-  });
-
-  //
-  FaxRoom
-    .findAll(query)
-    .then(function(res) {
-      res.forEach(function(fax) {
-        actionsGroup.rules.forEach(function(rule) {
-          switch (rule.field.value) {
-            case 'status':
-              setStatus(fax.id, rule.data);
-              break;
-            default:
-          }
-        });
-      });
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function setStatus(ticketId, newStatus) {
-  FaxRoom.update({
-      status: newStatus,
-    }, {
-      where: {
-        id: ticketId
-      }
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-function getCondition(rule) {
-  var result = {};
-  switch (rule.field.value) {
-    case 'status':
-      switch (rule.operator) {
-        case '=':
-          result[rule.field.value] = rule.data;
-          break;
-        case '<>':
-          result[rule.field.value] = {
-            $ne: rule.data
-          };
-          break;
-        default:
-      }
-      break;
-    case 'createdAt':
-      var compareDate = moment().subtract(parseInt(rule.data, 10), 'hours').format("YYYY-MM-DD HH:mm:ss");
-      switch (rule.operator) {
-        case '>':
-          result[rule.field.value] = {
-            lt: compareDate
-          };
-          break;
-        case '>=':
-          result[rule.field.value] = {
-            $lte: compareDate
-          };
-          break;
-        case '<':
-          result[rule.field.value] = {
-            $gt: compareDate
-          };
-          break;
-        case '<=':
-          result[rule.field.value] = {
-            $gte: compareDate
-          };
-          break;
-        default:
-      }
-      break;
-    default:
-  }
-  return result;
-}
-
-function createInterval(faxAutomation) {
-  activeAutomations['interval' + faxAutomation.id] = setInterval(function() {
-    executeAutomation(faxAutomation);
-  }, automationTimeout * 1000);
-}
-
-module.exports = function() {
-  getTimeout();
-
-  Automation.afterCreate(function(doc, options) {
-    createInterval(doc);
-  });
-
-  Automation.afterUpdate(function(doc, options) {
-    clearInterval(activeAutomations['interval' + doc.id]);
-    createInterval(doc);
-  });
-
-  Automation.afterDelete(function(doc, options) {
-    clearInterval(activeAutomations['interval' + doc.id]);
-  });
-
-  Automation
-    .findAll({
-      where: {
-        status: true,
-        channel: 'fax'
-      }
-    })
-    .then(function(faxAutomations) {
-
-      faxAutomations.forEach(function(faxAutomation) {
-        createInterval(faxAutomation);
-      });
-    })
-    .catch(function(err) {
-      console.error(err);
-    });
-};
\ No newline at end of file
diff --git a/server/config/automations/mail.js b/server/config/automations/mail.js
index ea76e97..cd448aa 100644
--- a/server/config/automations/mail.js
+++ b/server/config/automations/mail.js
@@ -1,169 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var config = require('../environment');
-var moment = require('moment');
-// var stringifyObject = require('stringify-object');
-
-var sequelize = require('../../models').sequelize;
-var Automation = require('../../models').Automation;
-var MailRoom = require('../../models').MailRoom;
-var Settings = require('../../models').Settings;
-var automationTimeout;
-var activeAutomations = {};
-
-function getTimeout() {
-  return Settings
-    .findOne()
-    .then(function (result) {
-      automationTimeout = result.automation_timeout;
-      return;
-    });
-}
-
-function executeAutomation(mailAutomation) {
-  var query = {
-    where: {}
-  };
-  var actions = {};
-  var conditionsGroup = JSON.parse(mailAutomation.conditions).group;
-  var actionsGroup = JSON.parse(mailAutomation.actions).group;
-  var subConditions = {};
-  var mainOp = conditionsGroup.boolean === 'AND' ? '$and' : '$or';
-  query.where[mainOp] = [];
-  conditionsGroup.rules.forEach(function (rule) {
-    if (rule.operator) {
-      // console.log('normal rule');
-      query.where[mainOp].push(getCondition(rule));
-    } else if (rule.group) {
-      // console.log('subgroup');
-      var subOp = rule.group.boolean === 'AND' ? '$and' : '$or';
-      var tempGroup = {};
-      tempGroup[subOp] = [];
-      rule.group.rules.forEach(function (subRule) {
-        // console.log('subgroup rule');
-        tempGroup[subOp].push(getCondition(subRule));
-      });
-      query.where[mainOp].push(tempGroup);
-    }
-  });
-
-  //
-  MailRoom
-    .findAll(query)
-    .then(function (res) {
-      res.forEach(function (mail) {
-        actionsGroup.rules.forEach(function (rule) {
-          switch (rule.field.value) {
-          case 'status':
-            setStatus(mail.id, rule.data);
-            break;
-          default:
-          }
-        });
-      });
-    })
-    .catch(function (err) {
-      console.log(err);
-    });
-}
-
-function setStatus(ticketId, newStatus) {
-  MailRoom.update({
-      status: newStatus,
-    }, {
-      where: {
-        id: ticketId
-      }
-    })
-    .catch(function (err) {
-      console.log(err);
-    });
-}
-
-function getCondition(rule) {
-  var result = {};
-  switch (rule.field.value) {
-  case 'status':
-    switch (rule.operator) {
-    case '=':
-      result[rule.field.value] = rule.data;
-      break;
-    case '<>':
-      result[rule.field.value] = {
-        $ne: rule.data
-      };
-      break;
-    default:
-    }
-    break;
-  case 'createdAt':
-    var compareDate = moment().subtract(parseInt(rule.data, 10), 'hours').format("YYYY-MM-DD HH:mm:ss");
-    switch (rule.operator) {
-    case '>':
-      result[rule.field.value] = {
-        lt: compareDate
-      };
-      break;
-    case '>=':
-      result[rule.field.value] = {
-        $lte: compareDate
-      };
-      break;
-    case '<':
-      result[rule.field.value] = {
-        $gt: compareDate
-      };
-      break;
-    case '<=':
-      result[rule.field.value] = {
-        $gte: compareDate
-      };
-      break;
-    default:
-    }
-    break;
-  default:
-  }
-  return result;
-}
-
-function createInterval(mailAutomation) {
-  activeAutomations['interval' + mailAutomation.id] = setInterval(function () {
-    executeAutomation(mailAutomation);
-  }, automationTimeout * 1000);
-}
-
-module.exports = function () {
-  getTimeout();
-
-  Automation.afterCreate(function (doc, options) {
-    createInterval(doc);
-  });
-
-  Automation.afterUpdate(function (doc, options) {
-    clearInterval(activeAutomations['interval' + doc.id]);
-    createInterval(doc);
-  });
-
-  Automation.afterDelete(function (doc, options) {
-    clearInterval(activeAutomations['interval' + doc.id]);
-  });
-
-  Automation
-    .findAll({
-      where: {
-        status: true,
-        channel: 'mail'
-      }
-    })
-    .then(function (mailAutomations) {
-
-      mailAutomations.forEach(function (mailAutomation) {
-        createInterval(mailAutomation);
-      });
-    })
-    .catch(function (err) {
-      console.error(err);
-    });
-};
\ No newline at end of file
diff --git a/server/config/environment/development.js b/server/config/environment/development.js
index 90dc82e..aa74b28 100644
--- a/server/config/environment/development.js
+++ b/server/config/environment/development.js
@@ -1,13 +1 @@
-'use strict';
-
-var dbconf = require('./dbconf.json').development;
-var dbconfhistory = require('./dbconfhistory.json').development;
-var astconf = require('./astconf.json').development;
-// Development specific configuration
-// ==================================
-module.exports = {
-  db: dbconf, // MySQL connection options
-  db_history: dbconfhistory, // MySQL connection options
-  asterisk: astconf, // Asterisk connection options
-  seedDB: true
-};
\ No newline at end of file
diff --git a/server/config/environment/index.js b/server/config/environment/index.js
index 476cd75..d8625fa 100644
--- a/server/config/environment/index.js
+++ b/server/config/environment/index.js
@@ -1,78 +1 @@
-'use strict';
-
-var path = require('path');
-var _ = require('lodash');
-
-function requiredProcessEnv(name) {
-  if (!process.env[name]) {
-    throw new Error('You must set the ' + name + ' environment variable');
-  }
-  return process.env[name];
-}
-
-// All configurations will extend these options
-// ============================================
-var all = {
-  env: process.env.NODE_ENV,
-
-  // Root path of server
-  root: path.normalize(__dirname + '/../../..'),
-
-  // Root path of server
-  moh: path.normalize(__dirname + '/../../..' + '/server/files/moh'),
-
-  // Server port
-  port: process.env.PORT || 9000,
-
-  // Server ip
-  ip: process.env.IP || 'localhost',
-
-  // Should we populate the DB with sample data?
-  seedDB: false,
-
-  // Secret for session, you will want to change this and make it an environment variable
-  session: {
-    name: 'xcally-motion-name',
-    secret: 'xcally-motion-secret',
-    token: 'xcally-motion-token',
-    cookie: {
-      path: '/',
-      httpOnly: true,
-      // If secure is set to true then it will cause the cookie to be set
-      // only when SSL-enabled (HTTPS) is used, and otherwise it won't
-      // set a cookie. 'true' is recommended yet it requires the above
-      // mentioned pre-requisite.
-      secure: false,
-      // Only set the maxAge to null if the cookie shouldn't be expired
-      // at all. The cookie will expunge when the browser is closed.
-      maxAge: null
-    }
-  },
-
-  // List of user roles
-  userRoles: ['guest', 'user', 'admin'],
-
-  facebook: {
-    clientID: process.env.FACEBOOK_ID || 'id',
-    clientSecret: process.env.FACEBOOK_SECRET || 'secret',
-    callbackURL: (process.env.DOMAIN || '') + '/auth/facebook/callback'
-  },
-
-  twitter: {
-    clientID: process.env.TWITTER_ID || 'id',
-    clientSecret: process.env.TWITTER_SECRET || 'secret',
-    callbackURL: (process.env.DOMAIN || '') + '/auth/twitter/callback'
-  },
-
-  google: {
-    clientID: process.env.GOOGLE_ID || 'id',
-    clientSecret: process.env.GOOGLE_SECRET || 'secret',
-    callbackURL: (process.env.DOMAIN || '') + '/auth/google/callback'
-  }
-};
-
-// Export the config object based on the NODE_ENV
-// ==============================================
-module.exports = _.merge(
-  all,
-  require('./' + process.env.NODE_ENV + '.js') || {});
\ No newline at end of file
diff --git a/server/config/environment/production.js b/server/config/environment/production.js
index 6d0faa4..3a249a8 100644
--- a/server/config/environment/production.js
+++ b/server/config/environment/production.js
@@ -1,13 +1 @@
-'use strict';
-
-var dbconf = require('./dbconf.json').production;
-var dbconfhistory = require('./dbconfhistory.json').production;
-var astconf = require('./astconf.json').production;
-// Production specific configuration
-// ==================================
-module.exports = {
-  db: dbconf, // MySQL connection options
-  db_history: dbconfhistory, // MySQL connection options
-  asterisk: astconf, // Asterisk connection options
-  seedDB: true
-};
\ No newline at end of file
diff --git a/server/config/environment/test.js b/server/config/environment/test.js
index 8d6bd9f..ce16b7e 100644
--- a/server/config/environment/test.js
+++ b/server/config/environment/test.js
@@ -1,13 +1 @@
-'use strict';
-
-var dbconf = require('./dbconf.json').test;
-var dbconfhistory = require('./dbconfhistory.json').test;
-var astconf = require('./astconf.json').test;
-// Test specific configuration
-// ==================================
-module.exports = {
-  db: dbconf, // MySQL connection options
-  db_history: dbconfhistory, // MySQL connection options
-  asterisk: astconf, // Asterisk connection options
-  seedDB: true
-};
\ No newline at end of file
diff --git a/server/config/express.js b/server/config/express.js
index 3054f8d..7485887 100644
--- a/server/config/express.js
+++ b/server/config/express.js
@@ -1,72 +1 @@
-/**
- * Express configuration
- */
-
-'use strict';
-
-var express = require('express');
-var favicon = require('serve-favicon');
-var morgan = require('morgan');
-var compression = require('compression');
-var bodyParser = require('body-parser');
-var methodOverride = require('method-override');
-var cookieParser = require('cookie-parser');
-var errorHandler = require('errorhandler');
-var path = require('path');
-var passport = require('passport');
-var session = require('express-session');
-var flash = require('connect-flash');
-var SessionStore = require('express-mysql-session');
-var session = require('express-session');
-var config = require('./environment');
-
-module.exports = function(app) {
-  var env = app.get('env');
-
-  app.set('views', config.root + '/server/views');
-  app.engine('html', require('ejs').renderFile);
-  app.set('view engine', 'html');
-  app.use(compression());
-  app.use(bodyParser.urlencoded({
-    extended: false
-  }));
-  app.use(bodyParser.json());
-  app.use(methodOverride());
-  app.use(cookieParser());
-  app.use(passport.initialize());
-
-  // Express/MySQL session storage
-  app.use(session({
-    secret: config.session.secret,
-    store: new SessionStore({
-      host: config.db.host,
-      port: config.db.port,
-      user: config.db.username,
-      password: config.db.password,
-      database: config.db.database
-    }),
-    cookie: config.session.cookie,
-    name: config.session.name,
-    resave: true,
-    saveUninitialized: true
-  }));
-
-  if ('production' === env) {
-    app.use(favicon(path.join(config.root, 'public', 'favicon.ico')));
-    app.use(express.static(path.join(config.root, 'public')));
-    app.set('appPath', config.root + '/public');
-    app.use(morgan('dev'));
-  }
-
-  if ('development' === env || 'test' === env) {
-    app.use(require('connect-livereload')());
-    app.use(express.static(path.join(config.root, '.tmp')));
-    app.use(express.static(path.join(config.root, 'client')));
-    app.set('appPath', 'client');
-    app.use(morgan('dev'));
-    app.use(errorHandler()); // Error handler - has to be last
-  }
-
-  // Connect flash for flash messages
-  app.use(flash());
-};
\ No newline at end of file
diff --git a/server/config/fax.js b/server/config/fax.js
index c64343b..c7083dd 100644
--- a/server/config/fax.js
+++ b/server/config/fax.js
@@ -1,240 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var uuidLib = require('node-uuid');
-var ConvertTiff = require('tiff-to-png');
-var exec = require('child_process').exec;
-var fs = require('fs');
-var path = require('path');
-
-var FaxMessage = require('../models').FaxMessage;
-var FaxRoom = require('../models').FaxRoom;
-var Contact = require('../models').Contact;
-var Event = require('../models').Event;
-var config = require('./environment');
-
-exports.register = function(ami) {
-
-  ami.on('receivefax', function(evt) {
-
-    FaxRoom
-      .create({
-        status: 'NEW',
-        from: evt.remotestationid,
-        FaxAccountId: 1, //TODO Handle account ID
-      })
-      .then(function(faxRoom) {
-
-        evt.status = 'RECEIVED';
-        evt.FaxRoomId = faxRoom.id;
-
-        FaxMessage
-          .create(evt)
-          .then(function(faxMessage) {
-
-            Event
-              .create({
-                name: 'INCOMING',
-                channel: 'FAX',
-                FaxRoomId: faxRoom.id,
-                FaxAccountId: 1 //TODO Handle account ID
-              })
-              .catch(function(err) {
-                console.error(err);
-              });
-
-            Contact
-              .findOrCreate({
-                where: {
-                  phone: evt.remotestationid
-                },
-                defaults: {
-                  phone: evt.remotestationid,
-                  fullname: evt.remotestationid
-                }
-              })
-              .spread(function(contact, created) {
-                faxMessage.setFrom(contact);
-              });
-
-            Contact
-              .findOrCreate({
-                where: {
-                  phone: evt.localstationid
-                },
-                defaults: {
-                  phone: evt.localstationid,
-                  fullname: evt.localstationid
-                }
-              })
-              .spread(function(contact, created) {
-                faxMessage.setTo(contact);
-              });
-
-            //Convert tiff to png
-            var uuid = uuidLib.v4();
-            var inputPath = evt.filename; //Restore for normal usage
-            // var inputPath = '/tmp/sample.tif' //Used for testing
-            var resultPath = path.join(config.root, 'server', 'files', 'fax', 'inbound', uuid + '.pdf');
-            var command = 'convert ' + inputPath + ' ' + resultPath;
-            fs.exists(inputPath, function(exists) {
-              if (exists) {
-                console.error('The file ' + inputPath + ' exits');
-                //Install ImageMagick for doing that!
-                exec(command, function(err) {
-                  if (err) {
-                    console.error(err);
-                  } else {
-                    faxMessage.updateAttributes({
-                        filenamePDF: uuid + '.pdf'
-                      })
-                      .then(function() {
-                        console.error('The file ' + inputPath + ' was converted in PDF');
-                      })
-                      .catch(function(err) {
-                        console.error(err);
-                      });
-                  }
-                });
-              } else {
-                console.error('The file ' + inputPath + ' does not exits');
-              }
-            });
-          })
-          .catch(function(err) {
-            console.error(err);
-          });
-
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  });
-
-  ami.on('sendfax', function(evt) {
-    console.log('***SendFAX***');
-
-    FaxMessage
-      .findOne({
-        where: {
-          uniqueid: evt.uniqueid
-        }
-      })
-      .then(function(faxMessage) {
-        if (faxMessage) {
-          faxMessage.updateAttributes(evt);
-        }
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-
-  });
-
-  ami.on('varset', function(evt) {
-    if (evt.variable.hasOwnProperty('faxstatus')) {
-      FaxMessage
-        .findOne({
-          where: {
-            uniqueid: evt.uniqueid
-          }
-        })
-        .then(function(faxMessage) {
-          if (faxMessage) {
-            console.log('VarSet: ', 'status', evt.value);
-            faxMessage.updateAttributes({
-              status: evt.value == 'FAILED' ? 'FAILED' : 'SENT'
-            });
-          }
-        })
-        .catch(function(err) {
-          console.error(err);
-        });
-    } else if (evt.variable.hasOwnProperty('faxerror')) {
-      FaxMessage
-        .findOne({
-          where: {
-            uniqueid: evt.uniqueid
-          }
-        })
-        .then(function(faxMessage) {
-          if (faxMessage) {
-            console.log('VarSet: ', 'error', evt.value);
-            faxMessage.updateAttributes({
-              error: evt.value
-            });
-          }
-        })
-        .catch(function(err) {
-          console.error(err);
-        });
-    } else if (evt.variable.hasOwnProperty('faxstatusstring')) {
-      FaxMessage
-        .findOne({
-          where: {
-            uniqueid: evt.uniqueid
-          }
-        })
-        .then(function(faxMessage) {
-          if (faxMessage) {
-            console.log('VarSet: ', 'laststatus', evt.value);
-            faxMessage.updateAttributes({
-              laststatus: evt.value
-            });
-          }
-        })
-        .catch(function(err) {
-          console.error(err);
-        });
-    }
-
-  });
-
-  ami.on('userevent', function(evt) {
-    if (evt.userevent === 'Fax') {
-      FaxMessage
-        .findOne({
-          where: {
-            uuid: evt.uuid
-          }
-        })
-        .then(function(faxMessage) {
-          if (faxMessage) {
-            evt.status = 'SENDING';
-            faxMessage.updateAttributes(evt);
-          }
-        })
-        .catch(function(err) {
-          console.error(err);
-        });
-    }
-
-  });
-
-  ami.on('faxstatus', function(evt) {
-    FaxMessage
-      .findOne({
-        where: {
-          uniqueid: evt.uniqueid
-        }
-      })
-      .then(function(faxMessage) {
-        if (faxMessage) {
-
-          console.log('FAXStatus: ', evt.uniqueid, evt.status);
-
-          faxMessage.updateAttributes({
-            operation: evt.operation,
-            laststatus: evt.status
-          });
-        }
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-
-  })
-
-  require('../api/fax_message/fax_message.ami').register(ami);
-
-};
\ No newline at end of file
diff --git a/server/config/history.js b/server/config/history.js
index f283c04..e732067 100644
--- a/server/config/history.js
+++ b/server/config/history.js
@@ -1,318 +1 @@
-"use strict";
-var moment = require('moment');
-var ReportAgent = require('../models').ReportAgent;
-var ReportCall = require('../models').ReportCall;
-var ReportDial = require('../models').ReportDial;
-var ReportMember = require('../models').ReportMember;
-var ReportQueue = require('../models').ReportQueue;
-var ReportIntegration = require('../models').ReportIntegration;
-var ReportMailSession = require('../models').ReportMailSession;
-
-var ReportAgentHistory = require('../models').history.ReportAgentHistory;
-var ReportCallHistory = require('../models').history.ReportCallHistory;
-var ReportDialHistory = require('../models').history.ReportDialHistory;
-var ReportMemberHistory = require('../models').history.ReportMemberHistory;
-var ReportQueueHistory = require('../models').history.ReportQueueHistory;
-var ReportIntegrationHistory = require('../models').history.ReportIntegrationHistory;
-var ReportMailSessionHistory = require('../models').history.ReportMailSessionHistory;
-
-function ReportAgentInReportAgentHistory() {
-  ReportAgent
-    .findAll({
-      where: {
-        createdAt: {
-          $lte: moment().format("YYYY-MM-DD HH:mm:ss")
-        },
-        reason: {
-          $ne: null
-        }
-      },
-      raw: true
-    })
-    .then(function(rows) {
-      console.log('[report_agent] found: ' + rows.length);
-      rows.forEach(function(row, key) {
-        ReportAgentHistory
-          .create(row)
-          .then(function() {
-            console.log('[report_agent] ' + row.id + ' row copied');
-            ReportAgent.destroy({
-              where: {
-                id: row.id
-              },
-              individualHooks: true
-            }).then(function(res) {
-              console.log('[report_agent] ' + row.id + ' row deleted');
-            }).catch(function(err) {
-              console.log('[report_agent] error: ' + err)
-            });
-          })
-          .catch(function(err) {
-            console.log('[report_agent] error: ' + err);
-          });
-      });
-    })
-    .catch(function(err) {
-      console.error('[report_agent] error: ' + err);
-    });
-}
-
-function ReportCallInReportCallHistory() {
-  ReportCall
-    .findAll({
-      where: {
-        createdAt: {
-          $lte: moment().format("YYYY-MM-DD HH:mm:ss")
-        }
-      },
-      raw: true
-    })
-    .then(function(rows) {
-      rows.forEach(function(row, key) {
-        console.log('[report_call] found: ' + rows.length);
-        ReportCallHistory
-          .create(row)
-          .then(function() {
-            console.log('[c] ' + row.id + ' row copied');
-            ReportCall.destroy({
-              where: {
-                id: row.id
-              },
-              individualHooks: true
-            }).then(function(res) {
-              console.log('[report_call] ' + row.id + ' row deleted');
-            }).catch(function(err) {
-              console.log('[report_call] error: ' + err)
-            });
-          })
-          .catch(function(err) {
-            console.log('[report_call] error: ' + err);
-          });
-      });
-    })
-    .catch(function(err) {
-      console.error('[report_call] error: ' + err);
-    });
-}
-
-function ReportDialInReportDialHistory() {
-  ReportDial
-    .findAll({
-      where: {
-        createdAt: {
-          $lte: moment().format("YYYY-MM-DD HH:mm:ss")
-        },
-        dialstatus: {
-          $ne: null
-        }
-      },
-      raw: true
-    })
-    .then(function(rows) {
-      console.log('[report_dial] found: ' + rows.length);
-      rows.forEach(function(row, key) {
-        ReportDialHistory
-          .create(row)
-          .then(function() {
-            console.log('[report_dial] ' + row.id + ' row copied');
-            ReportDial.destroy({
-              where: {
-                id: row.id
-              },
-              individualHooks: true
-            }).then(function(res) {
-              console.log('[report_dial] ' + row.id + ' row deleted');
-            }).catch(function(err) {
-              console.log('[report_dial] error: ' + err)
-            });
-          })
-          .catch(function(err) {
-            console.log('[report_dial] error: ' + err);
-          });
-      });
-    })
-    .catch(function(err) {
-      console.error('[report_dial] error: ' + err);
-    });
-}
-
-function ReportMemberInReportMemberHistory() {
-  ReportMember
-    .findAll({
-      where: {
-        createdAt: {
-          $lte: moment().format("YYYY-MM-DD HH:mm:ss")
-        },
-        exitdate: {
-          $ne: null
-        }
-      },
-      raw: true
-    })
-    .then(function(rows) {
-      console.log('[report_member] found: ' + rows.length);
-      rows.forEach(function(row, key) {
-        ReportMemberHistory
-          .create(row)
-          .then(function() {
-            console.log('[report_member] ' + row.id + ' row copied');
-            ReportMember.destroy({
-              where: {
-                id: row.id
-              },
-              individualHooks: true
-            }).then(function(res) {
-              console.log('[report_member] ' + row.id + ' row deleted');
-            }).catch(function(err) {
-              console.log('[report_member] error: ' + err)
-            });
-          })
-          .catch(function(err) {
-            console.log('[report_member] error: ' + err);
-          });
-      });
-    })
-    .catch(function(err) {
-      console.error('[report_member] error: ' + err);
-    });
-}
-
-function ReportQueueInReportQueueHistory() {
-  ReportQueue
-    .findAll({
-      where: {
-        createdAt: {
-          $lte: moment().format("YYYY-MM-DD HH:mm:ss")
-        },
-        queuecallerleaveAt: {
-          $ne: null
-        }
-      },
-      raw: true
-    })
-    .then(function(rows) {
-      console.log('[report_queue] found: ' + rows.length);
-      rows.forEach(function(row, key) {
-        ReportQueueHistory
-          .create(row)
-          .then(function() {
-            console.log('[report_queue] ' + row.id + ' row copied');
-            ReportQueue.destroy({
-              where: {
-                id: row.id
-              },
-              individualHooks: true
-            }).then(function(res) {
-              console.log('[report_queue] ' + row.id + ' row deleted');
-            }).catch(function(err) {
-              console.log('[report_queue] error: ' + err)
-            });
-          })
-          .catch(function(err) {
-            console.log('[report_queue] error: ' + err);
-          });
-      });
-    })
-    .catch(function(err) {
-      console.error('[report_queue] error: ' + err);
-    });
-}
-
-function ReportIntegrationInReportIntegrationHistory() {
-  ReportIntegration
-    .findAll({
-      where: {
-        createdAt: {
-          $lte: moment().format("YYYY-MM-DD HH:mm:ss")
-        }
-      },
-      raw: true
-    })
-    .then(function(rows) {
-      rows.forEach(function(row, key) {
-        console.log('[report_integration] found: ' + rows.length);
-        ReportIntegrationHistory
-          .create(row)
-          .then(function() {
-            console.log('[c] ' + row.id + ' row copied');
-            ReportIntegration.destroy({
-              where: {
-                id: row.id
-              },
-              individualHooks: true
-            }).then(function(res) {
-              console.log('[report_integration] ' + row.id + ' row deleted');
-            }).catch(function(err) {
-              console.log('[report_integration] error: ' + err)
-            });
-          })
-          .catch(function(err) {
-            console.log('[report_integration] error: ' + err);
-          });
-      });
-    })
-    .catch(function(err) {
-      console.error('[report_integration] error: ' + err);
-    });
-}
-
-function ReportMailSessionInReportMailSessionHistory() {
-  ReportMailSession
-    .findAll({
-      where: {
-        createdAt: {
-          $lte: moment().format("YYYY-MM-DD HH:mm:ss")
-        },
-        mailleaveAt: {
-          $ne: null
-        }
-      },
-      raw: true
-    })
-    .then(function(rows) {
-      console.log('[report_mail_session] found: ' + rows.length);
-      rows.forEach(function(row, key) {
-        ReportMailSessionHistory
-          .create(row)
-          .then(function() {
-            console.log('[report_mail_session] ' + row.id + ' row copied');
-            ReportMailSession.destroy({
-              where: {
-                id: row.id
-              },
-              individualHooks: true
-            }).then(function(res) {
-              console.log('[report_mail_session] ' + row.id + ' row deleted');
-            }).catch(function(err) {
-              console.log('[report_mail_session] error: ' + err)
-            });
-          })
-          .catch(function(err) {
-            console.log('[report_mail_session] error: ' + err);
-          });
-      });
-    })
-    .catch(function(err) {
-      console.error('[report_mail_session] error: ' + err);
-    });
-}
-
-module.exports = function(CronJob) {
-
-  // Every 1 Minute
-  var job = new CronJob({
-    cronTime: '0 */60 * * * *',
-    onTick: function() {
-      new ReportAgentInReportAgentHistory();
-      new ReportCallInReportCallHistory();
-      new ReportDialInReportDialHistory();
-      new ReportMemberInReportMemberHistory();
-      new ReportQueueInReportQueueHistory();
-      new ReportIntegrationInReportIntegrationHistory();
-      new ReportMailSessionInReportMailSessionHistory();
-    }
-  });
-  job.start();
-
-
-}
\ No newline at end of file
diff --git a/server/config/imap/imap.js b/server/config/imap/imap.js
index a894bad..b5654ed 100644
--- a/server/config/imap/imap.js
+++ b/server/config/imap/imap.js
@@ -1,551 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var path = require('path');
-var config = require('../environment');
-var ImapListener = require("mail-listener2");
-var MailServerIn = require('../../models').MailServerIn;
-var MailMessage = require('../../models').MailMessage;
-var MailRoom = require('../../models').MailRoom;
-var Contact = require('../../models').Contact;
-var ContactEmail = require('../../models').ContactEmail;
-var sequelize = require('../../models').sequelize;
-
-// Public
-module.exports = {
-  create: function (doc) {
-
-    var imap;
-
-    function onUpdate(doc) {
-      if (!doc.changed('state') && !doc.changed('source') && doc.username === imap.imap._config.user) {
-        console.log("MAIL - Account " + doc.username + " IMAP UPDATED");
-        imap.stop();
-        onSave(doc);
-      }
-    }
-
-    function onRemove(doc) {
-      if (doc.username === imap.imap._config.user) {
-        console.log("MAIL - Account " + doc.username + " IMAP DESTROY");
-        imap.stop();
-        imap = null;
-      }
-    }
-
-    function onSave(doc) {
-
-      if (imap) {
-        imap.stop(doc);
-        imap = null;
-      }
-
-      imap = new ImapListener({
-        username: doc.username,
-        password: doc.password,
-        host: doc.host,
-        port: doc.port,
-        tls: doc.ssl,
-        tlsOptions: {
-          rejectUnauthorized: false
-        },
-        mailbox: doc.mailbox, // mailbox to monitor
-        searchFilter: [doc.filter], // the search filter being used after an IDLE notification has been retrieved
-        markSeen: true, // all fetched email willbe marked as seen and not fetched next time
-        fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,,
-        mailParserOptions: {
-          streamAttachments: false
-        }, // options to be passed to mailParser lib.
-        attachments: true, // download attachments as they are encountered to the project directory
-        attachmentOptions: {
-          directory: path.join(config.root, 'server', 'files', 'attachments', '/')
-        } // specify a download directory for attachments
-      });
-
-      imap.start();
-
-      imap.on("server:connected", function () {
-        console.log("MAIL - Account " + doc.username + " IMAP CONNECTED");
-        // SETUP CONNECTED STATUS
-        return MailServerIn
-          .findById(doc.id)
-          .then(function (msi) {
-            return msi
-              .update({
-                state: 'CONNECTED'
-              });
-          })
-          .catch(function (err) {
-            console.error(err);
-          });
-      });
-
-      imap.on("server:disconnected", function () {
-        console.log("MAIL - Account " + doc.MailAccountId + " IMAP DISCONNECTED");
-        MailServerIn
-          .findById(doc.id)
-          .then(function (msi) {
-            msi
-              .updateAttributes({
-                state: 'DISCONNECTED'
-              });
-          })
-          .catch(function (err) {
-            console.error(err);
-          });
-      });
-
-      imap.on("error", function (err) {
-        console.log("MAIL - Account " + doc.MailAccountId + " IMAP ERROR", err);
-        MailServerIn
-          .findById(doc.id)
-          .then(function (msi) {
-            msi
-              .updateAttributes({
-                state: 'ERROR',
-                source: err.source
-              });
-          })
-          .catch(function (err) {
-            console.error(err);
-          });
-      });
-
-      imap.on("mail", function (msg, seqno, attributes) {
-        var _mRoom;
-        var _mMessage;
-        var _mFrom, _mTo, _mCc, _mBcc;
-
-        function createMailMessage(mailRoom) {
-          _mRoom = mailRoom;
-
-          return MailMessage
-            .create({
-              messageId: msg.messageId,
-              subject: msg.subject,
-              from: _.pluck(msg.from, 'address').join(';'),
-              to: msg.to ? _.pluck(msg.to, 'address').join(';') : null,
-              cc: msg.cc ? _.pluck(msg.cc, 'address').join(';') : null,
-              bcc: msg.cc ? _.pluck(msg.bcc, 'address').join(';') : null,
-              status: 'RECEIVED',
-              html: msg.html || null,
-              text: msg.text || null,
-              MailAttachments: msg.attachments || [],
-              MailRoomId: mailRoom.id,
-            });
-        }
-
-        function createFrom(mailMessage) {
-          _mMessage = mailMessage;
-
-          return ContactEmail
-            .findOrCreate({
-              where: {
-                email: _mMessage.from
-              },
-              defaults: {
-                email: _mMessage.from
-              }
-            });
-        }
-
-        function createTo(mFrom, created) {
-          var promises = [];
-          var tos = _mMessage.to ? _.pluck(msg.to, 'address') : [];
-          _mFrom = mFrom;
-
-          tos.forEach(function (email) {
-            promises.push(ContactEmail
-              .findOrCreate({
-                where: {
-                  email: email
-                },
-                defaults: {
-                  email: email
-                }
-              }));
-          });
-
-          return promises;
-        }
-
-        function createCc(mTo) {
-          var promises = [];
-          var ccs = _mMessage.cc ? _.pluck(msg.cc, 'address') : [];
-          _mTo = _.map(mTo, function (elm) {
-            return elm[0];
-          });
-
-          ccs.forEach(function (email) {
-            promises.push(ContactEmail
-              .findOrCreate({
-                where: {
-                  email: email
-                },
-                defaults: {
-                  email: email
-                }
-              }));
-          });
-
-          return promises;
-        }
-
-        function createBcc(mCc) {
-          var promises = [];
-          var bccs = _mMessage.bcc ? _.pluck(msg.bcc, 'address') : [];
-          _mCc = _.map(mCc, function (elm) {
-            return elm[0];
-          });
-
-          bccs.forEach(function (email) {
-            promises.push(ContactEmail
-              .findOrCreate({
-                where: {
-                  email: email
-                },
-                defaults: {
-                  email: email
-                }
-              }));
-          });
-
-          return promises;
-        }
-
-        function setBcc(mBcc) {
-          _mBcc = _.map(mBcc, function (elm) {
-            return elm[0];
-          });
-
-          return;
-        }
-
-        return sequelize.transaction(function (t) {
-          if (msg.inReplyTo) {
-            console.log('msg', msg);
-            return MailMessage
-              .findOne({
-                where: {
-                  messageId: msg.inReplyTo[0]
-                },
-                include: [{
-                  all: true
-                }]
-              })
-              .then(function (mailMessageParent) {
-                return mailMessageParent
-                  .getMailRoom();
-              })
-              .then(function (mailRoom) {
-                _mRoom = mailRoom;
-
-                return MailMessage
-                  .create({
-                    messageId: msg.messageId,
-                    subject: msg.subject,
-                    from: _.pluck(msg.from, 'address').join(';'),
-                    to: msg.to ? _.pluck(msg.to, 'address').join(';') : null,
-                    cc: msg.cc ? _.pluck(msg.cc, 'address').join(';') : null,
-                    bcc: msg.cc ? _.pluck(msg.bcc, 'address').join(';') : null,
-                    status: 'RECEIVED',
-                    html: msg.html || null,
-                    text: msg.text || null,
-                    MailAttachments: msg.attachments || [],
-                    MailRoomId: mailRoom.id,
-                  }, {
-                    include: [{
-                      all: true
-                    }],
-                    transaction: t
-                  });
-              })
-              .then(function (mailMessage) {
-                _mMessage = mailMessage;
-
-                return ContactEmail
-                  .findOrCreate({
-                    where: {
-                      email: _mMessage.from
-                    },
-                    defaults: {
-                      email: _mMessage.from
-                    },
-                    transaction: t
-                  });
-              })
-              .spread(function (mFrom, created) {
-                var promises = [];
-                var tos = _mMessage.to ? _.pluck(msg.to, 'address') : [];
-                _mFrom = mFrom;
-
-                tos.forEach(function (email) {
-                  promises.push(ContactEmail
-                    .findOrCreate({
-                      where: {
-                        email: email
-                      },
-                      defaults: {
-                        email: email
-                      },
-                      transaction: t
-                    }));
-                });
-
-                return promises;
-              })
-              .all()
-              .then(function (mTo) {
-                var promises = [];
-                var ccs = _mMessage.cc ? _.pluck(msg.cc, 'address') : [];
-                _mTo = _.map(mTo, function (elm) {
-                  return elm[0];
-                });
-
-                ccs.forEach(function (email) {
-                  promises.push(ContactEmail
-                    .findOrCreate({
-                      where: {
-                        email: email
-                      },
-                      defaults: {
-                        email: email
-                      },
-                      transaction: t
-                    }));
-                });
-
-                return promises;
-              })
-              .all()
-              .then(function (mCc) {
-                var promises = [];
-                var bccs = _mMessage.bcc ? _.pluck(msg.bcc, 'address') : [];
-                _mCc = _.map(mCc, function (elm) {
-                  return elm[0];
-                });
-
-                bccs.forEach(function (email) {
-                  promises.push(ContactEmail
-                    .findOrCreate({
-                      where: {
-                        email: email
-                      },
-                      defaults: {
-                        email: email
-                      },
-                      transaction: t
-                    }));
-                });
-
-                return promises;
-              })
-              .all()
-              .then(function (mBcc) {
-                _mBcc = _.map(mBcc, function (elm) {
-                  return elm[0];
-                });
-
-                return;
-              })
-              .then(function () {
-                return _mMessage
-                  .setFrom(_mFrom, {
-                    transaction: t
-                  });
-              })
-              .then(function () {
-                return _mMessage
-                  .setTo(_mTo, {
-                    transaction: t
-                  });
-              })
-              .then(function () {
-                return _mMessage
-                  .setCc(_mCc, {
-                    transaction: t
-                  });
-              })
-              .then(function () {
-                return _mMessage
-                  .setBcc(_mBcc, {
-                    transaction: t
-                  });
-              });
-
-          } else {
-            return MailRoom
-              .create({
-                roomId: msg.messageId,
-                subject: msg.subject,
-                from: _.pluck(msg.from, 'address').join(';'),
-                MailAccountId: doc.MailAccountId
-              }, {
-                transaction: t
-              })
-              .then(function (mailRoom) {
-                _mRoom = mailRoom;
-
-                return MailMessage
-                  .create({
-                    messageId: msg.messageId,
-                    subject: msg.subject,
-                    from: _.pluck(msg.from, 'address').join(';'),
-                    to: msg.to ? _.pluck(msg.to, 'address').join(';') : null,
-                    cc: msg.cc ? _.pluck(msg.cc, 'address').join(';') : null,
-                    bcc: msg.cc ? _.pluck(msg.bcc, 'address').join(';') : null,
-                    status: 'RECEIVED',
-                    html: msg.html || null,
-                    text: msg.text || null,
-                    MailAttachments: msg.attachments || [],
-                    MailRoomId: mailRoom.id,
-                  }, {
-                    include: [{
-                      all: true
-                    }],
-                    transaction: t
-                  });
-              })
-              .then(function (mailMessage) {
-                _mMessage = mailMessage;
-
-                return ContactEmail
-                  .findOrCreate({
-                    where: {
-                      email: _mMessage.from
-                    },
-                    defaults: {
-                      email: _mMessage.from
-                    },
-                    transaction: t
-                  });
-              })
-              .spread(function (mFrom, created) {
-                var promises = [];
-                var tos = _mMessage.to ? _.pluck(msg.to, 'address') : [];
-                _mFrom = mFrom;
-
-                tos.forEach(function (email) {
-                  promises.push(ContactEmail
-                    .findOrCreate({
-                      where: {
-                        email: email
-                      },
-                      defaults: {
-                        email: email
-                      },
-                      transaction: t
-                    }));
-                });
-
-                return promises;
-              })
-              .all()
-              .then(function (mTo) {
-                var promises = [];
-                var ccs = _mMessage.cc ? _.pluck(msg.cc, 'address') : [];
-                _mTo = _.map(mTo, function (elm) {
-                  return elm[0];
-                });
-
-                ccs.forEach(function (email) {
-                  promises.push(ContactEmail
-                    .findOrCrredieate({
-                      where: {
-                        email: email
-                      },
-                      defaults: {
-                        email: email
-                      },
-                      transaction: t
-                    }));
-                });
-
-                return promises;
-              })
-              .all()
-              .then(function (mCc) {
-                var promises = [];
-                var bccs = _mMessage.bcc ? _.pluck(msg.bcc, 'address') : [];
-                _mCc = _.map(mCc, function (elm) {
-                  return elm[0];
-                });
-
-                bccs.forEach(function (email) {
-                  promises.push(ContactEmail
-                    .findOrCreate({
-                      where: {
-                        email: email
-                      },
-                      defaults: {
-                        email: email
-                      },
-                      transaction: t
-                    }));
-                });
-
-                return promises;
-              })
-              .all()
-              .then(function (mBcc) {
-                _mBcc = _.map(mBcc, function (elm) {
-                  return elm[0];
-                });
-
-                return;
-              })
-              .then(function () {
-                return _mMessage
-                  .setFrom(_mFrom, {
-                    transaction: t
-                  });
-              })
-              .then(function () {
-                return _mMessage
-                  .setTo(_mTo, {
-                    transaction: t
-                  });
-              })
-              .then(function () {
-                return _mMessage
-                  .setCc(_mCc, {
-                    transaction: t
-                  });
-              })
-              .then(function () {
-                return _mMessage
-                  .setBcc(_mBcc, {
-                    transaction: t
-                  });
-              });
-          }
-        }).then(function (result) {
-          // Transaction has been committed
-          // result is whatever the result of the promise chain returned to the transaction callback
-          console.log(result);
-        }).catch(function (err) {
-          // Transaction has been rolled back
-          // err is whatever rejected the promise chain returned to the transaction callback
-          console.error(err);
-        });
-      });
-
-      imap.on("attachment", function (attachment) {
-        console.log(attachment.path);
-      });
-    }
-
-    onSave(doc);
-
-    MailServerIn.afterCreate(function (doc) {
-      onSave(doc);
-    });
-    // HANDLE ACCOUNT UPDATE/DELETE
-    MailServerIn.afterUpdate(function (doc) {
-      onUpdate(doc);
-    });
-    MailServerIn.afterDestroy(function (doc) {
-      onRemove(doc);
-    });
-  }
-};
\ No newline at end of file
diff --git a/server/config/imap/index.js b/server/config/imap/index.js
index 93d8098..6168ce3 100644
--- a/server/config/imap/index.js
+++ b/server/config/imap/index.js
@@ -1,30 +1 @@
-'use strict';
-
-var MailAccount = require('../../models').MailAccount;
-var MailServerIn = require('../../models').MailServerIn;
-
-module.exports = {
-  init: function () {
-    MailServerIn.afterCreate(function (doc) {
-      require('./imap').create(doc);
-    });
-
-    // Get all Mail Accounts
-    MailAccount
-      .findAll({
-        include: [{
-          all: true
-        }]
-      })
-      .then(function (mailAccounts) {
-        for (var i = 0; i < mailAccounts.length; i++) {
-          if (mailAccounts[i].MailServerIn) {
-            require('./imap').create(mailAccounts[i].MailServerIn);
-          }
-        }
-      })
-      .catch(function (err) {
-        console.error(err);
-      });
-  }
-};
\ No newline at end of file
diff --git a/server/config/integration.js b/server/config/integration.js
index 8b87bc5..dfc7a52 100644
--- a/server/config/integration.js
+++ b/server/config/integration.js
@@ -1,24 +1 @@
-'use strict';
-
-var path = require('path');
-var fs = require('fs');
-
-var Integration = require('../models').Integration;
-
-module.exports = function(io, ami) {
-
-  Integration
-    .findAll()
-    .then(function(integrations) {
-      integrations.forEach(function(integration) {
-        var info = path.parse(integration.path);
-        var file = path.join(info.dir, info.name, integration.main);
-        if (fs.existsSync(file)) {
-          require(file)(io, ami);
-        }
-      });
-    })
-    .catch(function(err) {
-      console.error(err);
-    });
-};
\ No newline at end of file
diff --git a/server/config/kue.chat.js b/server/config/kue.chat.js
index 7c62351..efa4b31 100644
--- a/server/config/kue.chat.js
+++ b/server/config/kue.chat.js
@@ -1,560 +1 @@
-  'use strict';
-
-  var _ = require('lodash');
-  var moment = require('moment');
-  var md5 = require('md5');
-
-  var ChatApplication = require('../models').ChatApplication;
-  var ChatWebsite = require('../models').ChatWebsite;
-  var ChatVisitor = require('../models').ChatVisitor;
-  var ChatMessage = require('../models').ChatMessage;
-  var ChatQueue = require('../models').ChatQueue;
-  var ChatRoom = require('../models').ChatRoom;
-  var Interval = require('../models').Interval;
-
-  var ReportChatSession = require('../models').ReportChatSession;
-  var ReportChat = require('../models').ReportChat;
-
-  var User = require('../models').User;
-
-  var timeouts = {};
-
-  module.exports = function (kue) {
-    var kueChat = kue.createQueue();
-    // KUE PROCESS
-    kueChat.process('chat', 20, function (job, done) {
-      onProcess(job, done);
-    });
-    // REPORT MAIL HOOKS
-    ReportChat.afterUpdate(function (doc) {
-      var _chatRoom;
-
-      if (doc.changed('agentconnectedAt')) {
-        if (timeouts[doc.uniqueid]) {
-          clearTimeout(timeouts[doc.uniqueid].timeout);
-          timeouts[doc.uniqueid].done();
-          delete timeouts[doc.uniqueid];
-        }
-
-        ChatRoom
-          .findById(doc.chatroomid)
-          .then(function (chatRoom) {
-            _chatRoom = chatRoom;
-
-            chatRoom
-              .addUser(doc.agentid, {
-                individualHooks: true
-              });
-          })
-          .then(function () {
-            _chatRoom
-              .update({
-                status: 'open'
-              });
-          })
-          .catch(function (err) {
-            console.error(err);
-          });
-
-        ReportChat
-          .update({
-            agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss"),
-            reason: "answered_elsewhere",
-            lastevent: "answered_elsewhere"
-          }, {
-            where: {
-              uniqueid: doc.uniqueid,
-              reason: null
-            },
-            individualHooks: true
-          })
-          .catch(function (err) {
-            console.error(err);
-          });
-
-        ReportChatSession
-          .update({
-            chatleaveAt: moment().format("YYYY-MM-DD HH:mm:ss"),
-            agentid: doc.agentid,
-            fullname: doc.fullname,
-            membername: doc.membername,
-            chatqueuename: doc.chatqueuename
-          }, {
-            where: {
-              uniqueid: doc.uniqueid,
-            },
-            individualHooks: true
-          })
-          .catch(function (err) {
-            console.error(err);
-          });
-      }
-    });
-    // CHAT VISITOR HOOKS
-    ChatVisitor.afterCreate(function (doc) {
-      onSave(kueChat, doc);
-    });
-  };
-
-  function onSave(kue, doc, cb) {
-    // CREATE KUE PROCESS
-    kue
-      .create('chat', doc.dataValues)
-      .save();
-  }
-
-  function onProcess(job, done) {
-    ChatWebsite
-      .findById(job.data.ChatWebsiteId, {
-        include: [{
-          model: ChatApplication,
-          include: [{
-            model: ChatQueue,
-            include: [{
-              model: User
-            }]
-          }, {
-            model: User
-          }, {
-            model: Interval,
-            include: [{
-              all: true
-            }]
-          }]
-        }]
-      })
-      .then(function (ChatWebsite) {
-        if (!ChatWebsite) {
-          done(new Error('No Available ChatApplications..'));
-          return;
-        }
-
-        if (!ChatWebsite.ChatApplications.length) {
-          done(new Error('DialPlan ended..'));
-          return;
-        }
-
-        job.data.ChatVisitorId = job.data.id;
-        var session = _.merge(job.data, ChatWebsite.dataValues);
-
-        // START CREATE/ASSIGN CHAT ROOM
-        ChatRoom
-          .create({
-            type: 'external',
-            ChatVisitorId: session.ChatVisitorId,
-            ChatWebsiteId: session.id
-          }, {
-            include: [{
-              all: true
-            }]
-          })
-          .then(function (chatRoom) {
-
-            onReportSession({
-              uniqueid: session.ChatVisitorId,
-              chatroomid: chatRoom.id,
-              visitorname: session.fullname,
-              visitoremail: session.email,
-              websitename: session.name,
-              websiteid: session.id,
-              websiteaddress: session.address,
-              chatjoinAt: moment().format("YYYY-MM-DD HH:mm:ss")
-            });
-
-            session.ChatApplications = _.sortBy(session.ChatApplications, 'priority');
-            onInvite(session, 0, 0, 0, 0, chatRoom, done);
-          })
-          .catch(function (err) {
-            console.error(err);
-          });
-        // END CREATE/ASSIGN CHAT ROOM
-      })
-      .catch(function (err) {
-        console.error(err);
-      });
-  }
-
-  function onInvite(data, i, j, holdtime, count, chatRoom, done) {
-    console.log('invite', 'i', i, 'j', j, 'holdtime', holdtime);
-    var timeout = 0;
-    var aTimeout;
-
-    if (i === data.ChatApplications.length) {
-      console.error('DialPlan ended..');
-
-      onReportSession({
-        uniqueid: data.ChatVisitorId,
-        mailunmanagedAt: moment().format("YYYY-MM-DD HH:mm:ss"),
-        mailleaveAt: moment().format("YYYY-MM-DD HH:mm:ss")
-      });
-
-      done(new Error('DialPlan ended..'));
-      return;
-    }
-
-    if (data.ChatApplications[i].ChatQueue) {
-      // QUEUE APPLICATION
-
-      // ONLINE AGENTS COUNTER
-      var online = _.countBy(data.ChatApplications[i].ChatQueue.Users, {
-        online: true
-      }).true;
-
-      if (online && onInterval(data.ChatApplications[i].Interval ? data.ChatApplications[i].Interval : data.ChatApplications[i].interval)) {
-        // AT LEAST ONE AVAILABLE AGENT
-        if (j === data.ChatApplications[i].ChatQueue.Users.length) {
-          if (data.ChatApplications[i].timeout > holdtime) {
-            onInvite(data, i, 0, holdtime, count, chatRoom, done);
-            return;
-          } else {
-            onInvite(data, ++i, 0, 0, count, chatRoom, done);
-            return;
-          }
-        }
-
-        switch (data.ChatApplications[i].ChatQueue.strategy) {
-        case 'rrmemory':
-          if (data.ChatApplications[i].ChatQueue.Users[j].online &&
-            onInterval(data.ChatApplications[i].Interval ? data.ChatApplications[i].Interval : data.ChatApplications[i].interval)) {
-            // AVAILABLE
-            timeout = (((data.ChatApplications[i].timeout - holdtime) > data.ChatApplications[i].ChatQueue.timeout) ?
-              data.ChatApplications[i].ChatQueue.timeout : (data.ChatApplications[i].timeout - holdtime));
-
-            onReport({
-              uniqueid: data.ChatVisitorId,
-              chatroomid: chatRoom.id,
-              visitorname: data.fullname,
-              visitoremail: data.email,
-              websitename: data.name,
-              websiteid: data.id,
-              websiteaddress: data.address,
-              sorting: count,
-              timeslot: timeout,
-              application: data.ChatApplications[i].app,
-              fullname: data.ChatApplications[i].ChatQueue.Users[j].fullname,
-              membername: data.ChatApplications[i].ChatQueue.Users[j].name,
-              agentid: data.ChatApplications[i].ChatQueue.Users[j].id,
-              chatqueuename: data.ChatApplications[i].ChatQueue.name,
-              lastevent: 'called',
-              holdtime: holdtime,
-              agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss")
-            });
-
-            console.log('queue', data.ChatApplications[i].ChatQueue.name, 'agent', data.ChatApplications[i].ChatQueue.Users[j].name, 'timeout', timeout, 'holdtime', holdtime);
-            aTimeout = setTimeout(function () {
-              onReportUpdate({
-                uniqueid: data.ChatVisitorId,
-                count: count,
-                reason: 'timeout',
-                lastevent: 'timeout',
-                agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss")
-              });
-
-              holdtime += timeout;
-              onInvite(data, i, ++j, holdtime, ++count, chatRoom, done);
-              return;
-            }, timeout * 1000);
-
-            if (!timeouts[data.ChatVisitorId]) {
-              timeouts[data.ChatVisitorId] = {};
-            }
-
-            timeouts[data.ChatVisitorId].timeout = aTimeout;
-            timeouts[data.ChatVisitorId].done = done;
-
-          } else {
-            onInvite(data, i, ++j, holdtime, count, chatRoom, done);
-            return;
-          }
-
-          break;
-        case 'beepall':
-
-          timeout = (((data.ChatApplications[i].timeout - holdtime) > data.ChatApplications[i].ChatQueue.timeout) ?
-            data.ChatApplications[i].ChatQueue.timeout : (data.ChatApplications[i].timeout - holdtime));
-
-          var users = [];
-          data.ChatApplications[i].ChatQueue.Users.forEach(function (user) {
-            if (user.online) {
-              users.push({
-                uniqueid: data.ChatVisitorId,
-                chatroomid: chatRoom.id,
-                sorting: count,
-                subject: data.subject,
-                timeslot: timeout,
-                from: data.from,
-                attachment: data.attachment,
-                accountname: data.name,
-                accountaddress: data.address,
-                application: data.ChatApplications[i].app,
-                fullname: user.fullname,
-                membername: user.name,
-                agentid: user.id,
-                chatqueuename: data.ChatApplications[i].ChatQueue.name,
-                lastevent: 'called',
-                holdtime: holdtime,
-                agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss"),
-
-                visitorname: data.fullname,
-                visitoremail: data.email,
-                websitename: data.name,
-                websiteid: data.id,
-                websiteaddress: data.address,
-              });
-            }
-          });
-
-          if (users.length && onInterval(data.ChatApplications[i].Interval ? data.ChatApplications[i].Interval : data.ChatApplications[i].interval)) {
-            onReport(users, true);
-            aTimeout = setTimeout(function () {
-              console.log('count', count);
-              onReportUpdate({
-                uniqueid: data.ChatVisitorId,
-                count: count,
-                reason: 'timeout',
-                lastevent: 'timeout',
-                agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss")
-              });
-              holdtime += timeout;
-              j += data.ChatApplications[i].ChatQueue.Users.length;
-              onInvite(data, i, j, holdtime, ++count, chatRoom, done);
-              return;
-            }, timeout * 1000);
-
-            if (!timeouts[data.ChatVisitorId]) {
-              timeouts[data.ChatVisitorId] = {};
-            }
-
-            timeouts[data.ChatVisitorId].timeout = aTimeout;
-            timeouts[data.ChatVisitorId].done = done;
-
-          } else {
-            console.log('queue', data.ChatApplications[i].ChatQueue.name, 'timeout', timeout, 'holdtime', holdtime);
-
-            onInvite(data, ++i, 0, 0, count, chatRoom, done);
-            return;
-          }
-
-          break;
-        default:
-          console.error('Unknown strategy');
-        }
-      } else {
-        onInvite(data, ++i, 0, 0, count, chatRoom, done);
-        return;
-      }
-    } else {
-      // AGENT APPLICATION
-      timeout = data.ChatApplications[i].timeout;
-      if (data.ChatApplications[i].User.online &&
-        onInterval(data.ChatApplications[i].Interval ? data.ChatApplications[i].Interval : data.ChatApplications[i].interval)) {
-        onReport({
-          uniqueid: data.ChatVisitorId,
-          chatroomid: chatRoom.id,
-          sorting: count,
-          subject: data.subject,
-          timeslot: timeout,
-          from: data.from,
-          attachment: data.attachment,
-          accountname: data.name,
-          accountaddress: data.address,
-          application: data.ChatApplications[i].app,
-          fullname: data.ChatApplications[i].User.fullname,
-          membername: data.ChatApplications[i].User.name,
-          agentid: data.ChatApplications[i].User.id,
-          lastevent: 'called',
-          holdtime: holdtime,
-          agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss"),
-
-          visitorname: data.fullname,
-          visitoremail: data.email,
-          websitename: data.name,
-          websiteid: data.id,
-          websiteaddress: data.address
-        });
-
-        console.log('agent', data.ChatApplications[i].User.name, 'timeout', timeout, 'holdtime', holdtime);
-
-        aTimeout = setTimeout(function () {
-          onReportUpdate({
-            uniqueid: data.ChatVisitorId,
-            count: count,
-            reason: 'timeout',
-            lastevent: 'timeout',
-            agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss")
-          });
-
-          onInvite(data, ++i, 0, 0, count, chatRoom, done);
-          return;
-        }, timeout * 1000);
-
-        if (!timeouts[data.ChatVisitorId]) {
-          timeouts[data.ChatVisitorId] = {};
-        }
-
-        timeouts[data.ChatVisitorId].timeout = aTimeout;
-        timeouts[data.ChatVisitorId].done = done;
-      } else {
-        onInvite(data, ++i, 0, 0, ++count, chatRoom, done);
-        return
-      }
-    }
-  }
-
-  function onReport(report, bulk) {
-    if (bulk) {
-      ReportChat
-        .bulkCreate(report, {
-          individualHooks: true
-        })
-        .catch(function (err) {
-          console.error(err);
-        });
-    } else {
-      ReportChat
-        .create(report)
-        .catch(function (err) {
-          console.error(err);
-        });
-    }
-  }
-
-  function onReportSession(report) {
-
-    ReportChatSession
-      .findOrCreate({
-        where: {
-          uniqueid: report.uniqueid
-        },
-        defaults: report
-      })
-      .spread(function (ReportChatSession, created) {
-        if (!created) {
-          ReportChatSession
-            .update(report, {
-              individualHooks: true
-            })
-            .catch(function (err) {
-              console.error(err);
-            });
-        }
-      });
-  }
-
-  function onReportUpdate(report) {
-    ReportChat
-      .update(report, {
-        where: {
-          uniqueid: report.uniqueid,
-          sorting: report.count
-        },
-        individualHooks: true
-      })
-      .catch(function (err) {
-        console.error(err);
-      });
-  }
-
-  function onInterval(interval) {
-    if (_.isObject(interval)) {
-      for (var i = 0; i < interval.SubIntervals.length; i++) {
-        if (!onCheckInterval(interval.SubIntervals[i].interval)) {
-          return false;
-        }
-      }
-      return true;
-    } else {
-      return onCheckInterval(interval);
-    }
-  }
-
-  function onCheckInterval(interval) {
-
-    var daysOfWeek = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
-    var daysOfMonth = [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];
-    var months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
-    var i, shift;
-
-    var tRange = interval.split(',')[0];
-    var dwRange = interval.split(',')[1];
-    var dmRange = interval.split(',')[2];
-    var mRange = interval.split(',')[3];
-    // TIME RANGE CHECKING
-    if (tRange !== '*') {
-      var time = moment().format("HH:mm");
-      var tFrom = tRange.split('-')[0];
-      var tTo = tRange.split('-')[1];
-
-      if ((time < tFrom) || (time > tTo)) {
-        console.log('TRANGE KO');
-        return false;
-      }
-    }
-    // DAYS OF WEEK RANGE CHECKING
-    if (dwRange !== '*') {
-      var cWeekDay = daysOfWeek[moment().day()];
-      var dwFrom = _.indexOf(daysOfWeek, dwRange.split('-')[0]);
-      var dwTo = _.indexOf(daysOfWeek, dwRange.split('-')[1]);
-
-      for (i = 0; i < dwFrom; i++) {
-        shift = daysOfWeek.shift();
-        daysOfWeek.push(shift);
-      }
-
-      dwFrom = _.indexOf(daysOfWeek, dwRange.split('-')[0]);
-      dwTo = _.indexOf(daysOfWeek, dwRange.split('-')[1]) + 1;
-
-      daysOfWeek = daysOfWeek.slice(dwFrom, dwTo);
-
-      if (!_.includes(daysOfWeek, cWeekDay)) {
-        console.log('DWRANGE KO');
-        return false;
-      }
-    }
-    // DAYS OF MONTH RANGE CHECKING
-    if (dmRange !== '*') {
-      var cMonthDay = moment().date();
-      var dmFrom = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[0], 10));
-      var dmTo = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[1]));
-
-      for (i = 0; i < dmFrom; i++) {
-        shift = daysOfMonth.shift();
-        daysOfMonth.push(shift);
-      }
-
-      dmFrom = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[0], 10));
-      dmTo = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[1]), 10) + 1;
-
-      daysOfMonth = daysOfMonth.slice(dmFrom, dmTo);
-
-      if (!_.includes(daysOfMonth, cMonthDay)) {
-        console.log('DMRANGE KO');
-        return false;
-      }
-    }
-    // MONTHS RANGE CHECKING
-    if (mRange !== '*') {
-      var cMonth = months[moment().month()];
-      var mFrom = _.indexOf(months, mRange.split('-')[0]);
-      var mTo = _.indexOf(months, mRange.split('-')[1]);
-
-      for (i = 0; i < mFrom; i++) {
-        shift = months.shift();
-        months.push(shift);
-      }
-
-      mFrom = _.indexOf(months, mRange.split('-')[0]);
-      mTo = _.indexOf(months, mRange.split('-')[1]) + 1;
-
-      months = months.slice(mFrom, mTo);
-
-      if (!_.includes(months, cMonth)) {
-        console.log('MRANGE KO');
-        return false;
-      }
-    }
-
-    console.log('INTERVAL OK');
-
-    return true;
-  }
\ No newline at end of file
diff --git a/server/config/kue.fax.js b/server/config/kue.fax.js
index bfc3743..591f3bd 100644
--- a/server/config/kue.fax.js
+++ b/server/config/kue.fax.js
@@ -1,316 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var config = require('./environment');
-var async = require('async');
-var sockets = {};
-var User = require('../models').User;
-var Event = require('../models').Event;
-var FaxQueue = require('../models').FaxQueue;
-
-function invite(data, i, j, io, done) {
-
-  var elapsed = 0;
-  var timeout = 0;
-  var body = [];
-  var users = [];
-
-  if (i === data.applications.length) {
-    body.push({
-      name: 'UNASSIGNED',
-      channel: 'FAX',
-      FaxRoomId: data.roomId,
-      FaxAccountId: data.accountId
-    });
-
-    traceEvent(body, function() {});
-
-    done(new Error('DialPlan ended..'));
-    return;
-  }
-
-  if (data.applications[i].FaxQueue) {
-
-    timeout = (((data.applications[i].timeout - elapsed) > data.applications[i].FaxQueue.timeout) ?
-      data.applications[i].FaxQueue.timeout : (data.applications[i].timeout - elapsed));
-
-    switch (data.applications[i].FaxQueue.strategy) {
-      case 'rrmemory':
-        body.push({
-          name: 'ATTEMPT',
-          channel: 'FAX',
-          timeout: timeout,
-          UserId: data.applications[i].users[j].id,
-          FaxRoomId: data.roomId,
-          FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null,
-          FaxAccountId: data.accountId,
-          FaxApplicationId: data.applications[i].id
-        });
-        users.push(data.applications[i].users[j].id);
-        break;
-      case 'beepall':
-        data.applications[i].users.forEach(function(user) {
-          var item = {
-            name: 'ATTEMPT',
-            channel: 'FAX',
-            timeout: timeout,
-            UserId: user.id,
-            FaxRoomId: data.roomId,
-            FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null,
-            FaxAccountId: data.accountId,
-            FaxApplicationId: data.applications[i].id
-          }
-          body.push(item);
-          users.push(user.id);
-        });
-        break;
-      default:
-        console.log('Strategy unknown..');
-    }
-
-    traceEvent(body, function() {
-      emitEvent(users, 'FAX:QUEUE:' + data.applications[i].FaxQueue.id, {
-        timeout: timeout,
-        roomId: data.roomId
-      }, function(userId) {
-        clearInterval(qInterval);
-        clearTimeout(aTimeout);
-        var body = [{
-          name: 'ASSIGNED',
-          channel: 'FAX',
-          timeout: timeout,
-          UserId: userId,
-          FaxRoomId: data.roomId,
-          FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null,
-          FaxAccountId: data.accountId,
-          FaxApplicationId: data.applications[i].id
-        }];
-        traceEvent(body, function() {
-          done();
-        });
-      });
-    });
-
-  } else {
-    // SET AGENT APPLICATION TIMEOUT
-    timeout = data.applications[i].timeout;
-
-    users.push(data.applications[i].users[j].id);
-    body = [{
-      name: 'ATTEMPT',
-      channel: 'FAX',
-      timeout: timeout,
-      UserId: data.applications[i].users[j].id,
-      FaxRoomId: data.roomId,
-      FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null,
-      FaxAccountId: data.accountId,
-      FaxApplicationId: data.applications[i].id
-    }];
-    traceEvent(body, function() {
-      emitEvent(users, 'FAX:AGENT:' + data.applications[i].users[j].id, {
-        timeout: data.applications[i].timeout,
-        roomId: data.roomId
-      }, function(userId) {
-        clearInterval(qInterval);
-        clearTimeout(aTimeout);
-        var body = [{
-          name: 'ASSIGNED',
-          channel: 'FAX',
-          timeout: timeout,
-          UserId: userId,
-          FaxRoomId: data.roomId,
-          FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null,
-          FaxAccountId: data.accountId,
-          FaxApplicationId: data.applications[i].id
-        }];
-        traceEvent(body, function() {
-          done();
-        });
-      });
-    });
-
-  }
-
-  var qInterval = setInterval(function() {
-    var timeout = 0;
-    // NEXT AGENT
-    j++;
-
-    if (j === data.applications[i].users.length) {
-      j = 0;
-    }
-
-    if (data.applications[i].FaxQueue) {
-
-      elapsed += data.applications[i].FaxQueue.timeout;
-
-      timeout = (((data.applications[i].timeout - elapsed) > data.applications[i].FaxQueue.timeout) ?
-        data.applications[i].FaxQueue.timeout : (data.applications[i].timeout - elapsed));
-
-      var body = [];
-      var users = [];
-
-      switch (data.applications[i].FaxQueue.strategy) {
-        case 'rrmemory':
-          var item = {
-            name: 'ATTEMPT',
-            channel: 'FAX',
-            timeout: timeout,
-            UserId: data.applications[i].users[j].id,
-            FaxRoomId: data.roomId,
-            FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null,
-            FaxAccountId: data.accountId,
-            FaxApplicationId: data.applications[i].id
-          };
-          body.push(item);
-          users.push(data.applications[i].users[j].id);
-          break;
-        case 'beepall':
-          data.applications[i].users.forEach(function(user) {
-            var item = {
-              name: 'ATTEMPT',
-              channel: 'FAX',
-              timeout: timeout,
-              UserId: user.id,
-              FaxRoomId: data.roomId,
-              FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null,
-              FaxAccountId: data.accountId,
-              FaxApplicationId: data.applications[i].id
-            }
-            body.push(item);
-            users.push(user.id);
-          });
-          break;
-        default:
-          console.log('Strategy unknown..');
-      }
-
-      traceEvent(body, function() {
-        emitEvent(users, 'FAX:QUEUE:' + data.applications[i].FaxQueue.id, {
-          timeout: timeout,
-          roomId: data.roomId
-        }, function(userId) {
-          console.log('userId', userId);
-          clearInterval(qInterval);
-          clearTimeout(aTimeout);
-          var body = [{
-            name: 'ASSIGNED',
-            channel: 'FAX',
-            timeout: timeout,
-            UserId: userId,
-            FaxRoomId: data.roomId,
-            FaxQueueId: data.applications[i].FaxQueue ? data.applications[i].FaxQueue.id : null,
-            FaxAccountId: data.accountId,
-            FaxApplicationId: data.applications[i].id
-          }];
-          traceEvent(body, function() {
-            done();
-          });
-        });
-      });
-
-    }
-  }, data.applications[i].FaxQueue ? data.applications[i].FaxQueue.timeout * 1000 : data.applications[i].timeout * 1000);
-
-  var aTimeout = setTimeout(function() {
-    clearInterval(qInterval);
-    invite(data, ++i, 0, io, done);
-  }, data.applications[i].timeout * 1000);
-}
-
-function processing(job, done, io) {
-  var elapsed = 0;
-  var applications = [
-    // INIT
-    function(callback) {
-      callback(null, job.data, done, io);
-    },
-    // BUILDING APPLICATION STRUCTURE
-    function(data, done, io, callback) {
-      for (var i = 0; i < data.applications.length; i++) {
-        switch (data.applications[i].app) {
-          case 'agent':
-            if (!data.applications[i].users) {
-              data.applications[i].users = [];
-            }
-
-            data.applications[i].users.push(data.applications[i].User);
-            break;
-          case 'queue':
-
-            for (var j = 0; j < data.applications[i].FaxQueue.Users.length; j++) {
-
-              if (!data.applications[i].users) {
-                data.applications[i].users = [];
-              }
-
-              data.applications[i].users.push(
-                data.applications[i].FaxQueue.Users[j]
-              );
-            }
-
-            break;
-          default:
-
-        }
-      }
-
-      callback(null, data, done, io);
-    }
-  ];
-
-  async.waterfall(applications,
-    // optional callback
-    function(err, data, done, io) {
-      invite(data, 0, 0, io, done);
-    });
-}
-
-function traceEvent(body, cb) {
-  Event
-    .bulkCreate(body)
-    .then(function() {
-      if (cb) {
-        cb();
-      }
-    })
-    .catch(function(err) {
-      console.error(err);
-    });
-}
-
-function emitEvent(users, event, params, cb) {
-  users.forEach(function(user) {
-    console.log(event, user);
-    if (sockets[user]) {
-      sockets[user].emit(event, params, cb);
-    }
-  });
-}
-
-module.exports = function(io, kue) {
-
-  var kueFax = kue.createQueue();
-
-  /**
-   * Queue processing statement
-   */
-  kueFax.process('fax', 20, function(job, done) {
-    processing(job, done, io);
-  });
-
-  require('../api/fax_room/fax_room.kue').register(kueFax);
-
-  io.on('connection', function(socket) {
-
-    if (socket.handshake.query.userId) {
-      sockets[socket.handshake.query.userId] = socket;
-    }
-
-    socket.on('disconnect', function() {
-      if (sockets[socket.handshake.query.userId]) {
-        delete sockets[socket.handshake.query.userId];
-      }
-    });
-  });
-}
\ No newline at end of file
diff --git a/server/config/kue.mail.js b/server/config/kue.mail.js
index d5f87d3..8d8f551 100644
--- a/server/config/kue.mail.js
+++ b/server/config/kue.mail.js
@@ -1,516 +1 @@
-  'use strict';
-
-  var _ = require('lodash');
-  var moment = require('moment');
-
-  var MailApplication = require('../models').MailApplication;
-  var MailAccount = require('../models').MailAccount;
-  var MailQueue = require('../models').MailQueue;
-  var MailRoom = require('../models').MailRoom;
-  var Interval = require('../models').Interval;
-
-  var ReportMailSession = require('../models').ReportMailSession;
-  var ReportMail = require('../models').ReportMail;
-
-  var User = require('../models').User;
-
-  var timeouts = {};
-
-  module.exports = function(kue) {
-    var kueMail = kue.createQueue();
-    // KUE PROCESS
-    kueMail.process('mail', 20, function(job, done) {
-      onProcess(job, done);
-    });
-    // REPORT MAIL HOOKS
-    ReportMail.afterUpdate(function(doc) {
-      if (doc.changed('agentconnectedAt')) {
-        if (timeouts[doc.uniqueid]) {
-          clearTimeout(timeouts[doc.uniqueid].timeout);
-          timeouts[doc.uniqueid].done();
-          delete timeouts[doc.uniqueid];
-        }
-
-        MailRoom
-          .findById(doc.uniqueid)
-          .then(function(mailRoom) {
-            mailRoom
-              .update({
-                UserId: doc.agentid
-              })
-          })
-          .catch(function(err) {
-            console.error(err);
-          });
-
-        ReportMail
-          .update({
-            agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss"),
-            reason: "answered_elsewhere",
-            lastevent: "answered_elsewhere"
-          }, {
-            where: {
-              uniqueid: doc.uniqueid,
-              reason: null
-            },
-            individualHooks: true
-          })
-          .catch(function(err) {
-            console.error(err);
-          });
-
-        ReportMailSession
-          .update({
-            mailleaveAt: moment().format("YYYY-MM-DD HH:mm:ss"),
-            fullname: doc.fullname,
-            membername: doc.membername,
-            mailqueuename: doc.mailqueuename
-          }, {
-            where: {
-              uniqueid: doc.uniqueid,
-            },
-            individualHooks: true
-          })
-          .catch(function(err) {
-            console.error(err);
-          });
-      }
-    });
-    // MAIL ROOM HOOKS
-    MailRoom.afterCreate(function(doc) {
-      onSave(kueMail, doc);
-    });
-    MailRoom.afterDestroy(function(doc) {
-      onSave(kueMail, doc);
-    });
-  };
-
-  function onSave(kue, doc, cb) {
-    if (doc.status === 'NEW') {
-      // CREATE KUE PROCESS
-      kue.create('mail', doc.dataValues).save();
-    }
-  }
-
-  function onProcess(job, done) {
-    MailAccount
-      .findById(job.data.MailAccountId, {
-        include: [{
-          model: MailApplication,
-          include: [{
-            model: MailQueue,
-            include: [{
-              model: User
-            }]
-          }, {
-            model: User
-          }, {
-            model: Interval,
-            include: [{
-              all: true
-            }]
-          }]
-        }]
-      })
-      .then(function(mailAccount) {
-        if (!mailAccount) {
-          done(new Error('No Available MailApplications..'));
-          return;
-        }
-
-        if (!mailAccount.MailApplications.length) {
-          done(new Error('DialPlan ended..'));
-          return;
-        }
-
-        job.data.MailRoomId = job.data.id;
-        var session = _.merge(job.data, mailAccount.dataValues);
-
-        onReportSession({
-          uniqueid: session.MailRoomId,
-          subject: session.subject,
-          from: session.from,
-          cc: session.cc,
-          attachment: session.attachment,
-          accountname: session.name,
-          accountaddress: session.address,
-          mailjoinAt: moment().format("YYYY-MM-DD HH:mm:ss")
-        });
-
-        session.MailApplications = _.sortBy(session.MailApplications, 'priority');
-        onInvite(session, 0, 0, 0, 0, done);
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  }
-
-  function onInvite(data, i, j, holdtime, count, done) {
-    console.log('invite', 'i', i, 'j', j, 'holdtime', holdtime);
-    var timeout = 0;
-    var aTimeout;
-
-    if (i === data.MailApplications.length) {
-      console.error('DialPlan ended..');
-
-      onReportSession({
-        uniqueid: data.MailRoomId,
-        mailunmanagedAt: moment().format("YYYY-MM-DD HH:mm:ss"),
-        mailleaveAt: moment().format("YYYY-MM-DD HH:mm:ss")
-      });
-
-      done(new Error('DialPlan ended..'));
-      return;
-    }
-
-    if (data.MailApplications[i].MailQueue) {
-      // QUEUE APPLICATION
-
-      // ONLINE AGENTS COUNTER
-      var online = _.countBy(data.MailApplications[i].MailQueue.Users, {
-        online: true
-      }).true;
-
-      if (online && onInterval(data.MailApplications[i].Interval ? data.MailApplications[i].Interval : data.MailApplications[i].interval)) {
-        // AT LEAST ONE AVAILABLE AGENT
-        if (j === data.MailApplications[i].MailQueue.Users.length) {
-          if (data.MailApplications[i].timeout > holdtime) {
-            onInvite(data, i, 0, holdtime, count, done);
-            return;
-          } else {
-            onInvite(data, ++i, 0, 0, count, done);
-            return;
-          }
-        }
-
-        switch (data.MailApplications[i].MailQueue.strategy) {
-          case 'rrmemory':
-            if (data.MailApplications[i].MailQueue.Users[j].online &&
-              onInterval(data.MailApplications[i].Interval ? data.MailApplications[i].Interval : data.MailApplications[i].interval)) {
-              // AVAILABLE
-              timeout = (((data.MailApplications[i].timeout - holdtime) > data.MailApplications[i].MailQueue.timeout) ?
-                data.MailApplications[i].MailQueue.timeout : (data.MailApplications[i].timeout - holdtime));
-
-              onReport({
-                uniqueid: data.MailRoomId,
-                sorting: count,
-                subject: data.subject,
-                timeslot: timeout,
-                from: data.from,
-                attachment: data.attachment,
-                accountname: data.name,
-                accountaddress: data.address,
-                application: data.MailApplications[i].app,
-                fullname: data.MailApplications[i].MailQueue.Users[j].fullname,
-                membername: data.MailApplications[i].MailQueue.Users[j].name,
-                agentid: data.MailApplications[i].MailQueue.Users[j].id,
-                mailqueuename: data.MailApplications[i].MailQueue.name,
-                lastevent: 'called',
-                holdtime: holdtime,
-                agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss")
-              });
-
-              console.log('queue', data.MailApplications[i].MailQueue.name, 'agent', data.MailApplications[i].MailQueue.Users[j].name, 'timeout', timeout, 'holdtime', holdtime);
-              aTimeout = setTimeout(function() {
-                onReportUpdate({
-                  uniqueid: data.MailRoomId,
-                  count: count,
-                  reason: 'timeout',
-                  lastevent: 'timeout',
-                  agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss")
-                });
-
-                holdtime += timeout;
-                onInvite(data, i, ++j, holdtime, ++count, done);
-                return;
-              }, timeout * 1000);
-
-              if (!timeouts[data.MailRoomId]) {
-                timeouts[data.MailRoomId] = {};
-              }
-
-              timeouts[data.MailRoomId].timeout = aTimeout;
-              timeouts[data.MailRoomId].done = done;
-
-            } else {
-              onInvite(data, i, ++j, holdtime, count, done);
-              return;
-            }
-
-            break;
-          case 'beepall':
-
-            timeout = (((data.MailApplications[i].timeout - holdtime) > data.MailApplications[i].MailQueue.timeout) ?
-              data.MailApplications[i].MailQueue.timeout : (data.MailApplications[i].timeout - holdtime));
-
-            var users = [];
-            data.MailApplications[i].MailQueue.Users.forEach(function(user) {
-              if (user.online) {
-                users.push({
-                  uniqueid: data.MailRoomId,
-                  sorting: count,
-                  subject: data.subject,
-                  timeslot: timeout,
-                  from: data.from,
-                  attachment: data.attachment,
-                  accountname: data.name,
-                  accountaddress: data.address,
-                  application: data.MailApplications[i].app,
-                  fullname: user.fullname,
-                  membername: user.name,
-                  agentid: user.id,
-                  mailqueuename: data.MailApplications[i].MailQueue.name,
-                  lastevent: 'called',
-                  holdtime: holdtime,
-                  agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss")
-                });
-              }
-            });
-
-            if (users.length && onInterval(data.MailApplications[i].Interval ? data.MailApplications[i].Interval : data.MailApplications[i].interval)) {
-              onReport(users, true);
-              aTimeout = setTimeout(function() {
-                console.log('count', count);
-                onReportUpdate({
-                  uniqueid: data.MailRoomId,
-                  count: count,
-                  reason: 'timeout',
-                  lastevent: 'timeout',
-                  agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss")
-                });
-                holdtime += timeout;
-                j += data.MailApplications[i].MailQueue.Users.length;
-                onInvite(data, i, j, holdtime, ++count, done);
-                return;
-              }, timeout * 1000);
-
-              if (!timeouts[data.MailRoomId]) {
-                timeouts[data.MailRoomId] = {};
-              }
-
-              timeouts[data.MailRoomId].timeout = aTimeout;
-              timeouts[data.MailRoomId].done = done;
-
-            } else {
-              console.log('queue', data.MailApplications[i].MailQueue.name, 'timeout', timeout, 'holdtime', holdtime);
-
-              onInvite(data, ++i, 0, 0, count, done);
-              return;
-            }
-
-            break;
-          default:
-            console.error('Unknown strategy');
-        }
-      } else {
-        onInvite(data, ++i, 0, 0, count, done);
-        return;
-      }
-    } else {
-      // AGENT APPLICATION
-      timeout = data.MailApplications[i].timeout;
-      if (data.MailApplications[i].User.online &&
-        onInterval(data.MailApplications[i].Interval ? data.MailApplications[i].Interval : data.MailApplications[i].interval)) {
-        onReport({
-          uniqueid: data.MailRoomId,
-          sorting: count,
-          subject: data.subject,
-          timeslot: timeout,
-          from: data.from,
-          attachment: data.attachment,
-          accountname: data.name,
-          accountaddress: data.address,
-          application: data.MailApplications[i].app,
-          fullname: data.MailApplications[i].User.fullname,
-          membername: data.MailApplications[i].User.name,
-          agentid: data.MailApplications[i].User.id,
-          lastevent: 'called',
-          holdtime: holdtime,
-          agentcalledAt: moment().format("YYYY-MM-DD HH:mm:ss")
-        });
-
-        console.log('agent', data.MailApplications[i].User.name, 'timeout', timeout, 'holdtime', holdtime);
-
-        aTimeout = setTimeout(function() {
-          onReportUpdate({
-            uniqueid: data.MailRoomId,
-            count: count,
-            reason: 'timeout',
-            lastevent: 'timeout',
-            agentringnoanswerAt: moment().format("YYYY-MM-DD HH:mm:ss")
-          });
-
-          onInvite(data, ++i, 0, 0, count, done);
-          return;
-        }, timeout * 1000);
-
-        if (!timeouts[data.MailRoomId]) {
-          timeouts[data.MailRoomId] = {};
-        }
-
-        timeouts[data.MailRoomId].timeout = aTimeout;
-        timeouts[data.MailRoomId].done = done;
-      } else {
-        onInvite(data, ++i, 0, 0, ++count, done);
-        return
-      }
-    }
-  }
-
-  function onReport(report, bulk) {
-    if (bulk) {
-      ReportMail
-        .bulkCreate(report, {
-          individualHooks: true
-        })
-        .catch(function(err) {
-          console.error(err);
-        });
-    } else {
-      ReportMail
-        .create(report)
-        .catch(function(err) {
-          console.error(err);
-        });
-    }
-  }
-
-  function onReportSession(report) {
-
-    ReportMailSession
-      .findOrCreate({
-        where: {
-          uniqueid: report.uniqueid
-        },
-        defaults: report
-      })
-      .spread(function(reportMailSession, created) {
-        if (!created) {
-          reportMailSession
-            .update(report, {
-              individualHooks: true
-            })
-            .catch(function(err) {
-              console.error(err);
-            });
-        }
-      });
-  }
-
-  function onReportUpdate(report) {
-    ReportMail
-      .update(report, {
-        where: {
-          uniqueid: report.uniqueid,
-          sorting: report.count
-        },
-        individualHooks: true
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  }
-
-  function onInterval(interval) {
-    if (_.isObject(interval)) {
-      for (var i = 0; i < interval.SubIntervals.length; i++) {
-        if (!onCheckInterval(interval.SubIntervals[i].interval)) {
-          return false;
-        }
-      }
-      return true;
-    } else {
-      return onCheckInterval(interval);
-    }
-  }
-
-  function onCheckInterval(interval) {
-
-    var daysOfWeek = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
-    var daysOfMonth = [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];
-    var months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
-    var i, shift;
-
-    var tRange = interval.split(',')[0];
-    var dwRange = interval.split(',')[1];
-    var dmRange = interval.split(',')[2];
-    var mRange = interval.split(',')[3];
-    // TIME RANGE CHECKING
-    if (tRange !== '*') {
-      var time = moment().format("HH:mm");
-      var tFrom = tRange.split('-')[0];
-      var tTo = tRange.split('-')[1];
-
-      if ((time < tFrom) || (time > tTo)) {
-        console.log('TRANGE KO');
-        return false;
-      }
-    }
-    // DAYS OF WEEK RANGE CHECKING
-    if (dwRange !== '*') {
-      var cWeekDay = daysOfWeek[moment().day()];
-      var dwFrom = _.indexOf(daysOfWeek, dwRange.split('-')[0]);
-      var dwTo = _.indexOf(daysOfWeek, dwRange.split('-')[1]);
-
-      for (i = 0; i < dwFrom; i++) {
-        shift = daysOfWeek.shift();
-        daysOfWeek.push(shift);
-      }
-
-      dwFrom = _.indexOf(daysOfWeek, dwRange.split('-')[0]);
-      dwTo = _.indexOf(daysOfWeek, dwRange.split('-')[1]) + 1;
-
-      daysOfWeek = daysOfWeek.slice(dwFrom, dwTo);
-
-      if (!_.includes(daysOfWeek, cWeekDay)) {
-        console.log('DWRANGE KO');
-        return false;
-      }
-    }
-    // DAYS OF MONTH RANGE CHECKING
-    if (dmRange !== '*') {
-      var cMonthDay = moment().date();
-      var dmFrom = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[0], 10));
-      var dmTo = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[1]));
-
-      for (i = 0; i < dmFrom; i++) {
-        shift = daysOfMonth.shift();
-        daysOfMonth.push(shift);
-      }
-
-      dmFrom = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[0], 10));
-      dmTo = _.indexOf(daysOfMonth, parseInt(dmRange.split('-')[1]), 10) + 1;
-
-      daysOfMonth = daysOfMonth.slice(dmFrom, dmTo);
-
-      if (!_.includes(daysOfMonth, cMonthDay)) {
-        console.log('DMRANGE KO');
-        return false;
-      }
-    }
-    // MONTHS RANGE CHECKING
-    if (mRange !== '*') {
-      var cMonth = months[moment().month()];
-      var mFrom = _.indexOf(months, mRange.split('-')[0]);
-      var mTo = _.indexOf(months, mRange.split('-')[1]);
-
-      for (i = 0; i < mFrom; i++) {
-        shift = months.shift();
-        months.push(shift);
-      }
-
-      mFrom = _.indexOf(months, mRange.split('-')[0]);
-      mTo = _.indexOf(months, mRange.split('-')[1]) + 1;
-
-      months = months.slice(mFrom, mTo);
-
-      if (!_.includes(months, cMonth)) {
-        console.log('MRANGE KO');
-        return false;
-      }
-    }
-
-    console.log('INTERVAL OK');
-
-    return true;
-  }
\ No newline at end of file
diff --git a/server/config/local.env.sample.js b/server/config/local.env.sample.js
index 58ae668..7c2b260 100644
--- a/server/config/local.env.sample.js
+++ b/server/config/local.env.sample.js
@@ -1,23 +1 @@
-'use strict';
-
-// Use local.env.js for environment variables that grunt will set when the server starts locally.
-// Use for your api keys, secrets, etc. This file should not be tracked by git.
-//
-// You will need to set these on the server you deploy to.
-
-module.exports = {
-  DOMAIN:           'http://localhost:9000',
-  SESSION_SECRET:   'xcallyshuttle-secret',
-
-  FACEBOOK_ID:      'app-id',
-  FACEBOOK_SECRET:  'secret',
-
-  TWITTER_ID:       'app-id',
-  TWITTER_SECRET:   'secret',
-
-  GOOGLE_ID:        'app-id',
-  GOOGLE_SECRET:    'secret',
-
-  // Control debug level for modules using visionmedia/debug
-  DEBUG: ''
-};
\ No newline at end of file
diff --git a/server/config/logger.js b/server/config/logger.js
index 1542f7e..2235a58 100644
--- a/server/config/logger.js
+++ b/server/config/logger.js
@@ -1,120 +1 @@
-var winston = require('winston');
-var path = require('path');
-var config = require('./environment');
-
-winston.emitErrs = true;
-
-var debug = new winston.Logger({
-  transports: [
-    new winston.transports.Console({
-      level: 'debug',
-      handleExceptions: true,
-      json: false,
-      colorize: true
-    })
-  ]
-});
-
-if (config.logging.debugToFile) {
-  debug.add(
-    winston.transports.File, {
-      name: 'debug-file',
-      level: 'debug',
-      filename: config.logging.debug,
-      handleExceptions: true,
-      json: true,
-      maxsize: 5242880, //5MB
-      maxFiles: 5,
-      colorize: false
-    }
-  );
-}
-
-var info = new winston.Logger({
-  transports: [
-    new winston.transports.File({
-      name: 'info-file',
-      level: 'info',
-      filename: config.logging.info,
-      handleExceptions: true,
-      json: true,
-      maxsize: 5242880, //5MB
-      maxFiles: 5,
-      colorize: false
-    }),
-    new winston.transports.Console({
-      level: 'info',
-      handleExceptions: true,
-      json: false,
-      colorize: true
-    })
-  ]
-});
-
-var warn = new winston.Logger({
-  transports: [
-    new winston.transports.File({
-      name: 'warn-file',
-      level: 'warn',
-      filename: config.logging.warn,
-      handleExceptions: true,
-      json: true,
-      maxsize: 5242880, //5MB
-      maxFiles: 5,
-      colorize: false
-    }),
-    new winston.transports.Console({
-      level: 'warn',
-      handleExceptions: true,
-      json: false,
-      colorize: true
-    })
-  ]
-});
-
-var error = new winston.Logger({
-  transports: [
-    new winston.transports.File({
-      name: 'error-file',
-      level: 'error',
-      filename: config.logging.error,
-      handleExceptions: true,
-      json: true,
-      maxsize: 5242880, //5MB
-      maxFiles: 5,
-      colorize: false
-    }),
-    new winston.transports.Console({
-      level: 'error',
-      handleExceptions: true,
-      json: false,
-      colorize: true
-    })
-  ]
-});
-
-var loggers = {
-  debug: function(msg, callback) {
-    debug.debug(msg, callback);
-  },
-  info: function(msg, callback) {
-    info.info(msg, callback);
-  },
-  warn: function(msg, callback) {
-    warn.warn(msg, callback);
-  },
-  error: function(msg, callback) {
-    error.error(msg, callback);
-  },
-  log: function(level, msg, callback) {
-    var lvl = exports[level];
-    lvl(msg, callback);
-  }
-};
-
-module.exports = loggers;
-module.exports.stream = {
-  write: function(message, encoding) {
-    loggers.info(message);
-  }
-};
\ No newline at end of file
diff --git a/server/config/seed.js b/server/config/seed.js
index becaf69..6f58d59 100644
--- a/server/config/seed.js
+++ b/server/config/seed.js
@@ -1,1072 +1 @@
-/**
- * Populate DB with sample data on server start
- * to disable, edit config/environment/index.js, and set `seedDB: false`
- */
-
-'use strict';
-
-var _ = require('lodash');
-var models = require('../models');
-
-models.User
-  .bulkCreate([{
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Giuseppe Careri',
-    email: [email-masked]',
-    name: 'giuseppe.careri',
-    password: '75xcally75',
-    defaultuser: 'giuseppe.careri',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1000
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Daniele Cinti',
-    email: [email-masked]',
-    name: 'daniele.cinti',
-    password: '75xcally75',
-    defaultuser: 'daniele.cinti',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1001
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Andrea Bianco',
-    email: [email-masked]',
-    name: 'andrea.bianco',
-    password: '75xcally75',
-    defaultuser: 'andrea.bianco',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1002
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Massimiliano Bungaro',
-    email: [email-masked]',
-    name: 'massimiliano.bungaro',
-    password: '75xcally75',
-    defaultuser: 'massimiliano.bungaro',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1003
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Valerio Ciotta',
-    email: [email-masked]',
-    name: 'valerio.ciotta',
-    password: '75xcally75',
-    defaultuser: 'valerio.ciotta',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1004
-  }, {
-    provider: 'local',
-    role: 'admin',
-    fullname: 'Clarotech',
-    email: [email-masked]',
-    name: 'clarotech',
-    password: 'clarotech',
-    defaultuser: 'clarotech',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1005
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Abigael',
-    email: [email-masked]',
-    name: 'abigael',
-    password: '75xcally75',
-    defaultuser: 'abigael',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1006
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Tony Russell',
-    email: [email-masked]',
-    name: 'tony.russell',
-    password: 'clarotech',
-    defaultuser: 'tony.russell',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1007
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Colin Fair',
-    email: [email-masked]',
-    name: 'colin.fair',
-    password: 'clarotech',
-    defaultuser: 'colin.fair',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1008
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Diego Gosmar',
-    email: [email-masked]',
-    name: 'diego.gosmar',
-    password: '75xcally75',
-    defaultuser: 'diego.gosmar',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1009
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Giuseppe Innamorato',
-    email: [email-masked]',
-    name: 'giuseppe.innamorato',
-    password: '75xcally75',
-    defaultuser: 'giuseppe.innamorato',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'upd',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1010
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Alessandra Bessone',
-    email: [email-masked]',
-    name: 'alessandra.bessone',
-    password: '75xcally75',
-    defaultuser: 'alessandra.bessone',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'upd',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1011
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Felice Briscese',
-    email: [email-masked]',
-    name: 'felice.briscese',
-    password: '75xcally75',
-    defaultuser: 'felice.briscese',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'upd',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1012
-  }, {
-    provider: 'local',
-    role: 'admin',
-    fullname: 'xCally',
-    email: [email-masked]',
-    name: 'xcally',
-    password: '388xshuttle388',
-    defaultuser: 'xcally',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1013
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'John Doe',
-    email: [email-masked]',
-    name: 'john.doe',
-    password: '75xcally75',
-    defaultuser: 'john.doe',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1014
-  }, {
-    provider: 'local',
-    role: 'agent',
-    fullname: 'Jane Miller',
-    email: [email-masked]',
-    name: 'jane.miller',
-    password: '75xcally75',
-    defaultuser: 'jane.miller',
-    host: 'dynamic',
-    type: 'FRIEND',
-    transport: 'udp',
-    allow: 'alaw;ulaw;gsm',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    disallow: 'all',
-    context: 'from-sip',
-    internal: 1015
-  }], {
-    ignoreDuplicates: true,
-    individualHooks: true
-  }).then(function() {
-    console.log('Finished populating users');
-  });
-
-models.Trunk
-  .bulkCreate([{
-    name: 'citalia',
-    type: 'friend',
-    insecure: 'port,invite',
-    defaultuser: '01119827770',
-    secret: 'T!NPnv-qjCMe9v',
-    password: 'T!NPnv-qjCMe9v',
-    context: 'from-voip-provider',
-    language: 'it',
-    host: 'voip.eutelia.it',
-    fromdomain: 'voip.eutelia.it',
-    dtmfmode: 'rfc2833',
-    qualify: 'yes',
-    nat: 'force_rport,comedia',
-    callerid: ' "" <>',
-    limitonpeers: 'yes',
-    callcounter: 'yes',
-    disallow: 'all',
-    allow: 'ulaw;alaw;gsm',
-    canreinvite: 'no',
-    directmedia: 'no'
-  }], {
-    ignoreDuplicates: true,
-    individualHooks: true
-  }).then(function() {
-    console.log('Finished populating trunks');
-  });
-
-
-// Init modules table
-models.Module
-  .bulkCreate([{
-    name: "dashboard",
-    title: "APPLICATION_DASHBOARD"
-  }, {
-    name: "users",
-    title: "APPLICATION_USERS"
-  }, {
-    name: "agents",
-    title: "APPLICATION_AGENTS"
-  }, {
-    name: "teams",
-    title: "APPLICATION_TEAMS"
-  }, {
-    name: "chat",
-    title: "APPLICATION_CHAT"
-  }, {
-    name: "voice",
-    title: "APPLICATION_VOICE"
-  }, {
-    name: "mail",
-    title: "APPLICATION_MAIL"
-  }, {
-    name: "fax",
-    title: "APPLICATION_FAX"
-  }, {
-    name: "audio",
-    title: "APPLICATION_AUDIO"
-  }, {
-    name: "callysquare",
-    title: "APPLICATION_CALLYSQUARE"
-  }, {
-    name: "analytics",
-    title: "APPLICATION_ANALYTICS"
-  }, {
-    name: "realtime",
-    title: "APPLICATION_REALTIME"
-  }, {
-    name: "voicemails",
-    title: "APPLICATION_VOICEMAILS"
-  }, {
-    name: "settings",
-    title: "APPLICATION_SETTINGS"
-  }], {
-    ignoreDuplicates: true
-  }).then(function() {
-    console.log('Finished populating modules');
-  });
-
-models.Team
-  .create({
-    name: "T1",
-    description: "Default Team",
-    defaultEntry: true
-  })
-  .then(function(team) {
-
-    models.User
-      .findAll({
-        where: {
-          role: 'agent'
-        }
-      })
-      .then(function(users) {
-        team
-          .addUsers(_.pluck(users, 'id'))
-          .then(function() {
-            models.ChatQueue
-              .create({
-                name: "CQ1",
-                description: "CQ1 Desc",
-                timeout: 5,
-                strategy: "rrmemory"
-              })
-              .then(function(chatQueue) {
-                console.log('Finished populating chat queue 1');
-
-                models.Team
-                  .findOne({
-                    where: {
-                      name: 'T1'
-                    },
-                    include: [{
-                      all: true
-                    }]
-                  })
-                  .then(function(team) {
-                    chatQueue
-                      .addUsers(_.pluck(team.Users, 'id'))
-                      .catch(function(err) {
-                        // console.error(err);
-                      });
-                  })
-                  .catch(function(err) {
-                    // console.error(err);
-                  });
-              });
-
-            models.MailQueue
-              .create({
-                name: "MQ1",
-                description: "MQ1 Desc",
-                timeout: 5,
-                strategy: "rrmemory"
-              })
-              .then(function(mailQueue) {
-                console.log('Finished populating mail queue 1');
-
-                models.Team
-                  .findOne({
-                    where: {
-                      name: 'T1'
-                    },
-                    include: [{
-                      all: true
-                    }]
-                  })
-                  .then(function(team) {
-                    if (team) {
-                      console.log('team found');
-                    } else {
-                      console.log('test');
-                    }
-                    mailQueue
-                      .addUsers(_.pluck(team.Users, 'id'))
-                      .catch(function(err) {
-                        // console.error(err);
-                      });
-                  })
-                  .catch(function(err) {
-                    // console.error(err);
-                  });
-              });
-
-            models.FaxQueue
-              .create({
-                name: "FQ1",
-                description: "FQ1 Desc",
-                timeout: 5,
-                strategy: "rrmemory"
-              })
-              .then(function(faxQueue) {
-                console.log('Finished populating fax queue 1');
-
-                models.Team
-                  .findOne({
-                    where: {
-                      name: 'T1'
-                    },
-                    include: [{
-                      all: true
-                    }]
-                  })
-                  .then(function(team) {
-                    faxQueue
-                      .addUsers(_.pluck(team.Users, 'id'))
-                      .catch(function(err) {
-                        // console.error(err);
-                      });
-                  })
-                  .catch(function(err) {
-                    // console.error(err);
-                  });
-              });
-          })
-          .catch(function(err) {
-            // console.error(err);
-          });
-      })
-      .catch(function(err) {
-        // console.error(err);
-      });
-  })
-  .catch(function(err) {
-    // console.error(err);
-  });
-
-models.MailAccount
-  .create({
-    name: "xCally Development",
-    description: "xCally Development",
-    address: "[email-masked]"
-  })
-  .then(function(mailAccount) {
-    console.log('Finished populating mail account');
-    models.MailServerIn
-      .create({
-        description: 'xcally',
-        host: 'imap.xcally.com',
-        username: [email-masked]',
-        password: 'phokucloka',
-        port: 143,
-        mailbox: 'INBOX',
-        ssl: false,
-        delete: false,
-        filter: 'UNSEEN',
-        protocol: 'IMAP',
-        MailAccountId: mailAccount.id
-      })
-      .then(function() {
-        console.log('Finished populating mail server in');
-        models.MailServerOut
-          .create({
-            description: 'xcally',
-            host: 'smtp.xcally.com',
-            username: [email-masked]',
-            password: 'phokucloka',
-            port: 587,
-            ssl: false,
-            MailAccountId: mailAccount.id
-          })
-          .then(function() {
-            console.log('Finished populating mail server out');
-          })
-          .catch(function(err) {
-            // console.error(err);
-          });
-      })
-      .catch(function(err) {
-        // console.error(err);
-      });
-  });
-
-models.FaxAccount
-  .create({
-    description: 'FA1 Desc',
-    name: 'FA1',
-    phone: '01119827770',
-    ecm: true,
-    faxheader: 'xCALLY',
-    localid: '01119827770',
-    maxrate: '9600',
-    minrate: '14400',
-  })
-  .then(function(faxAccount) {
-    console.log('Finished populating fax account');
-
-    models.Trunk
-      .findOne({
-        where: {
-          name: 'citalia'
-        }
-      })
-      .then(function(trunk) {
-        faxAccount
-          .setTrunk(trunk)
-          .catch(function(err) {
-            // console.error(err);
-          });
-
-
-        models.VoiceExtension
-          .create({
-            context: 'from-voip-provider',
-            exten: '01119827770',
-            priority: 1,
-            app: 'Goto',
-            appdata: 'inbound-fax,s,1',
-            type: 'inbound-fax',
-            TrunkId: trunk.id
-          })
-
-      })
-      .catch(function(err) {
-        // console.error(err);
-      });
-
-    models.FaxQueue
-      .findAll()
-      .then(function(faxQueues) {
-        models.FaxApplication
-          .create({
-            app: 'queue',
-            appdata: faxQueues[0].id,
-            priority: 1,
-            timeout: 30,
-            FaxAccountId: faxAccount.id,
-            FaxQueueId: faxQueues[0].id
-          })
-          .then(function() {
-            console.log('Finished populating chat website application 1');
-          })
-          .catch(function(err) {
-            // console.error(err);
-          });
-
-        models.FaxApplication
-          .create({
-            app: 'queue',
-            appdata: faxQueues[1].id,
-            priority: 2,
-            timeout: 30,
-            FaxAccountId: faxAccount.id,
-            FaxQueueId: faxQueues[1].id
-          })
-          .then(function() {
-            console.log('Finished populating chat website application 2');
-          })
-          .catch(function(err) {
-            // console.error(err);
-          });
-      })
-      .catch(function(err) {
-        // console.error(err);
-      });
-  })
-  .catch(function(err) {
-    // console.error(err);
-  });
-
-models.VoiceExtension
-  .bulkCreate([{
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 1,
-    app: 'NoOp',
-    appdata: 'Fax UUID: ${FAXUUID}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 2,
-    app: 'UserEvent',
-    appdata: 'Fax,uuid: ${FAXUUID}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 3,
-    app: 'Set',
-    appdata: 'FAXOPT(filename):${FAXFILE}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 4,
-    app: 'Set',
-    appdata: 'FAXOPT(ecm):${ECM}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 5,
-    app: 'Set',
-    appdata: 'FAXOPT(headerinfo):${FAXHEADER}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 6,
-    app: 'Set',
-    appdata: 'FAXOPT(localstationid):${LOCALID}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 7,
-    app: 'Set',
-    appdata: 'FAXOPT(maxrate):${MAXRATE}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 8,
-    app: 'Set',
-    appdata: 'FAXOPT(minrate):${MINRATE}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 9,
-    app: 'SendFAX',
-    appdata: '${FAXFILE},d',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 's',
-    priority: 10,
-    app: 'NoOp',
-    appdata: 'ERROR "${TIMESTAMP}" "NO_STATUS" "NO_PAGES"',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 'h',
-    priority: 1,
-    app: 'NoOp',
-    appdata: 'FAXOPT(ecm) : ${FAXOPT(ecm)}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 'h',
-    priority: 2,
-    app: 'NoOp',
-    appdata: 'FaxStatus : ${FAXSTATUS}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 'h',
-    priority: 3,
-    app: 'NoOp',
-    appdata: 'FaxStatusString : ${FAXSTATUSSTRING}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 'h',
-    priority: 4,
-    app: 'NoOp',
-    appdata: 'FaxError : ${FAXERROR}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 'h',
-    priority: 5,
-    app: 'NoOp',
-    appdata: 'RemoteStationID : ${REMOTESTATIONID}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 'h',
-    priority: 6,
-    app: 'NoOp',
-    appdata: 'FaxPages : ${FAXPAGES}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 'h',
-    priority: 7,
-    app: 'NoOp',
-    appdata: 'FaxBitRate : ${FAXBITRATE}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 'h',
-    priority: 8,
-    app: 'NoOp',
-    appdata: 'FaxResolution : ${FAXRESOLUTION}',
-    type: 'outbound-fax'
-  }, {
-    context: 'outbound-fax',
-    exten: 'h',
-    priority: 9,
-    app: 'NoOp',
-    appdata: 'OK "${TIMESTAMP}" "${FAXSTATUSSTRING}" "${FAXPAGES}"',
-    type: 'outbound-fax'
-  }], {
-    ignoreDuplicates: true
-  })
-  .then(function() {
-    console.log('Finished populating fax outbound voice extension');
-  });
-
-models.VoiceExtension
-  .bulkCreate([{
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 1,
-    app: 'NoOp',
-    appdata: '**** FAX RECEIVED from ${CALLERID(num)} ${STRFTIME(${EPOCH},,%c)} ****',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 2,
-    app: 'Set',
-    appdata: 'FAXOPT(ecm):yes',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 3,
-    app: 'Set',
-    appdata: 'FILENAME:${UNIQUEID}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 4,
-    app: 'Set',
-    appdata: 'FAXFILE:${FILENAME}.tif',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 5,
-    app: 'Set',
-    appdata: 'FAXOPT(headerinfo):Received by XeniaLAB ${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M)}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 6,
-    app: 'Set',
-    appdata: 'FAXOPT(localstationid):${LOCALID}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 7,
-    app: 'Set',
-    appdata: 'FAXOPT(maxrate):${MAXRATE}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 8,
-    app: 'Set',
-    appdata: 'FAXOPT(minrate):${MINRATE}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 9,
-    app: 'NoOp',
-    appdata: 'FAXOPT(ecm) : ${FAXOPT(ecm)}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 10,
-    app: 'NoOp',
-    appdata: 'FAXOPT(headerinfo) : ${FAXOPT(headerinfo)}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 11,
-    app: 'NoOp',
-    appdata: 'FAXOPT(localstationid) : ${FAXOPT(localstationid)}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 12,
-    app: 'NoOp',
-    appdata: 'FAXOPT(maxrate) : ${FAXOPT(maxrate)}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 13,
-    app: 'NoOp',
-    appdata: 'FAXOPT(minrate) : ${FAXOPT(minrate)}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 14,
-    app: 'NoOp',
-    appdata: '**** RECEIVING FAX : ${FAXFILE} ****',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 15,
-    app: 'ReceiveFax',
-    appdata: '/tmp/${FAXFILE}',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 's',
-    priority: 16,
-    app: 'Hangup',
-    type: 'inbound-fax'
-  }, {
-    context: 'inbound-fax',
-    exten: 'h',
-    priority: 1,
-    app: 'NoOp',
-    appdata: 'FAXOPT(ecm) : ${FAXOPT(ecm)}',
-    type: 'inbound-fax'
-  }], {
-    ignoreDuplicates: true
-  })
-  .then(function() {
-    console.log('Finished populating fax outbound voice extension');
-  });
-
-models.SquareProject
-  .bulkCreate([{
-    name: "project1",
-    description: "description project"
-  }], {
-    ignoreDuplicates: true
-  }).then(function() {
-    console.log('Finished populating square projects');
-  });
-
-models.ChatWebsite
-  .create({
-    name: 'xCally Shop',
-    description: 'xCally Shop',
-    address: 'http://www.xcally.com/shop/',
-    color: '#f51111',
-    color_focus: '#f51111',
-    color_button: '#f51111',
-    remote: 'http://185.43.210.57:9000',
-    animation: true,
-    header_shape: 'squared',
-    header_online: 'We are here!',
-    online_message: 'Questions? Insert your name and email address to start a live-chat with our support team.',
-    username_placeholder: 'Your name',
-    email_placeholder: 'Your email address',
-    start_chat_button: 'Chat',
-    header_offline: 'Contact us',
-    offline_message: "'<strong>We're not online.</strong><br />It doesn't mean we're not there to help - leave your message below and we'll be in touch as soon as possible.'",
-    enquiry_message_placeholder: 'Your message...',
-    enquiry_button: 'Leave message',
-    download_transcript: true
-  })
-  .then(function(chatWebsite) {
-    console.log('Finished populating chat website');
-    models.ChatQueue
-      .findAll()
-      .then(function(chatQueues) {
-        models.ChatApplication
-          .create({
-            app: 'queue',
-            appdata: chatQueues[0].id,
-            priority: 1,
-            timeout: 30,
-            ChatWebsiteId: chatWebsite.id,
-            ChatQueueId: chatQueues[0].id
-          })
-          .then(function() {
-            console.log('Finished populating chat website application 1');
-          })
-          .catch(function(err) {
-            // console.error(err);
-          });
-
-        models.ChatApplication
-          .create({
-            app: 'queue',
-            appdata: chatQueues[1].id,
-            priority: 2,
-            timeout: 30,
-            ChatWebsiteId: chatWebsite.id,
-            ChatQueueId: chatQueues[1].id
-          })
-          .then(function() {
-            console.log('Finished populating chat website application 2');
-          })
-          .catch(function(err) {
-            // console.error(err);
-          });
-      })
-      .catch(function(err) {
-        // console.error(err);
-      });
-  })
-  .catch(function(err) {
-    // console.error(err);
-  });
-
-models.Variable
-  .bulkCreate([{
-    name: "variable1",
-    description: "description project"
-  }], {
-    ignoreDuplicates: true
-  }).then(function() {
-    console.log('Finished populating variables');
-  });
-
-models.VoiceContext
-  .bulkCreate([{
-    name: "from-sip",
-    description: "Default context (DO NOT DELETE)",
-    defaultEntry: true
-  }, {
-    name: "from-voip-provider",
-    description: "Default context (DO NOT DELETE)",
-    defaultEntry: true
-  }, {
-    name: "inbound-fax",
-    description: "Default context (DO NOT DELETE)",
-    defaultEntry: true
-  }, {
-    name: "outbound-fax",
-    description: "Default context (DO NOT DELETE)",
-    defaultEntry: true
-  }], {
-    ignoreDuplicates: true,
-    individualHooks: true
-  }).then(function() {
-    console.log('Finished populating context variables');
-  });
-
-models.VoiceMusicOnHold
-  .bulkCreate([{
-    name: "default",
-    mode: "files",
-    directory: 'var/lib/asterisk/moh',
-    sort: 'alpha',
-    format: 'wav',
-    defaultEntry: true
-  }], {
-    ignoreDuplicates: true,
-    individualHooks: true
-  }).then(function() {
-    console.log('Finished populating moh variables');
-  });
-
-models.Settings
-  .bulkCreate([{
-    mac: '00-50-FC-A0-67-2C',
-    netmask: '255.255.255.0',
-    address: '127.0.0.1',
-    min_internal: 1000
-  }], {
-    ignoreDuplicates: true,
-    individualHooks: true
-  }).then(function() {
-    console.log('Finished populating moh variables');
-  });
-
-models.Dashboard
-  .bulkCreate([{
-    name: 'Motion Dashboard',
-    model: JSON.stringify({
-      title: 'Motion Dashboard',
-      rows: [{
-        columns: [{
-          styleClass: 'col-md-4',
-          widgets: [{
-            type: 'clock',
-            title: 'Clock',
-            config: {
-              timePattern: 'hh:mm:ss a',
-              datePattern: 'dddd, MMMM Do YYYY'
-            }
-          }]
-        }, {
-          styleClass: 'col-md-8',
-          widgets: [{
-            type: 'iframe',
-            title: 'Iframe',
-            config: {
-              url: 'https://demo.xcally.com/shop/'
-            }
-          }]
-        }]
-      }]
-    }),
-    defaultEntry: true
-  }], {
-    ignoreDuplicates: true,
-    individualHooks: true
-  }).then(function() {
-    console.log('Finished populating moh variables');
-  });
\ No newline at end of file
diff --git a/server/config/smtp/index.js b/server/config/smtp/index.js
index e5bf8e2..c38ad53 100644
--- a/server/config/smtp/index.js
+++ b/server/config/smtp/index.js
@@ -1,24 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var MailServerOut = require('../../models').MailServerOut;
-
-module.exports = {
-  init: function () {
-
-    MailServerOut.afterCreate(function (doc) {
-      require('./smtp').create(doc);
-    });
-
-    return MailServerOut
-      .findAll()
-      .then(function (data) {
-        data.forEach(function (elm) {
-          require('./smtp').create(elm);
-        });
-      })
-      .catch(function (err) {
-        console.error(err);
-      });
-  }
-};
\ No newline at end of file
diff --git a/server/config/smtp/smtp.js b/server/config/smtp/smtp.js
index 422a01b..1568712 100644
--- a/server/config/smtp/smtp.js
+++ b/server/config/smtp/smtp.js
@@ -1,428 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var nodemailer = require('nodemailer');
-var smtpTransport = require('nodemailer-smtp-transport');
-
-var Contact = require('../../models').Contact;
-var MailRoom = require('../../models').MailRoom;
-var MailMessage = require('../../models').MailMessage;
-var ContactEmail = require('../../models').ContactEmail;
-var MailServerOut = require('../../models').MailServerOut;
-
-module.exports = {
-  create: function (doc) {
-
-    var _smtp;
-    var _doc;
-
-    function onSave(doc) {
-      console.log("MAIL - Account " + doc.username + " SMTP CREATE");
-      _doc = doc;
-      _smtp = nodemailer.createTransport(smtpTransport({
-        host: doc.host,
-        port: doc.port,
-        secure: doc.ssl,
-        debug: true,
-        auth: {
-          user: doc.username,
-          pass: doc.password
-        }
-      }));
-    }
-
-    function onUpdate(doc) {
-      if (_smtp.transporter.options.auth.user === doc.username) {
-        console.log("MAIL - Account " + doc.username + " SMTP UPDATE");
-        _smtp = null;
-        _smtp = nodemailer.createTransport(smtpTransport({
-          host: doc.host,
-          port: doc.port,
-          secure: doc.ssl,
-          debug: true,
-          auth: {
-            user: doc.username,
-            pass: doc.password
-          }
-        }));
-      }
-    }
-
-    function onRemove(doc) {
-      if (_smtp.transporter.options.auth.user === doc.username) {
-        console.log("[MAIL - Account " + doc.username + " SMTP DESTROY");
-        _smtp = null;
-      }
-    }
-
-    function onSend(mailMessage, options) {
-      if (mailMessage.changed('status') && mailMessage.status === 'SENDING' && _smtp.transporter.options.auth.user === mailMessage.from) {
-        console.log('onSend', mailMessage.from);
-        var _mRoom;
-        var _mMessage = mailMessage;
-        var _mFrom, _mTo, _mCc, _mBcc;
-
-        if (_mMessage.inReplyTo) {
-          return MailMessage
-            .findOne({
-              where: {
-                messageId: _mMessage.inReplyTo
-              }
-            })
-            .then(function (mailMessageParent) {
-              return mailMessageParent
-                .getMailRoom();
-            })
-            .then(function (mailRoom) {
-              _mRoom = mailRoom;
-              return mailRoom
-                .addMailMessage(_mMessage, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              return ContactEmail
-                .findOrCreate({
-                  where: {
-                    email: _mMessage.from
-                  },
-                  defaults: {
-                    email: _mMessage.from
-                  },
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .spread(function (mFrom, created) {
-              var promises = [];
-              var tos = _mMessage.to ? _mMessage.to.split(';') : [];
-              _mFrom = mFrom;
-
-              tos.forEach(function (email) {
-                promises.push(ContactEmail
-                  .findOrCreate({
-                    where: {
-                      email: email
-                    },
-                    defaults: {
-                      email: email
-                    },
-                    transaction: options ? options.transaction : null
-                  }));
-              });
-
-              return promises;
-            })
-            .all()
-            .then(function (mTo) {
-              var promises = [];
-              var ccs = _mMessage.cc ? _mMessage.cc.split(';') : [];
-              _mTo = _.map(mTo, function (elm) {
-                return elm[0];
-              });
-
-              ccs.forEach(function (email) {
-                promises.push(ContactEmail
-                  .findOrCreate({
-                    where: {
-                      email: email
-                    },
-                    defaults: {
-                      email: email
-                    },
-                    transaction: options ? options.transaction : null
-                  }));
-              });
-
-              return promises;
-            })
-            .all()
-            .then(function (mCc) {
-              var promises = [];
-              var bccs = _mMessage.bcc ? _mMessage.bcc.split(';') : [];
-              _mCc = _.map(mCc, function (elm) {
-                return elm[0];
-              });
-
-              bccs.forEach(function (email) {
-                promises.push(ContactEmail
-                  .findOrCreate({
-                    where: {
-                      email: email
-                    },
-                    defaults: {
-                      email: email
-                    },
-                    transaction: options ? options.transaction : null
-                  }));
-              });
-
-              return promises;
-            })
-            .all()
-            .then(function (mBcc) {
-              _mBcc = _.map(mBcc, function (elm) {
-                return elm[0];
-              });
-
-              return;
-            })
-            .then(function () {
-              return _mMessage
-                .setFrom(_mFrom, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              return _mMessage
-                .setTo(_mTo, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              return _mMessage
-                .setCc(_mCc, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              return _mMessage
-                .setBcc(_mBcc, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              var mail = {
-                status: _mMessage.status,
-                from: _mMessage.from,
-                to: _mMessage.to,
-                cc: _mMessage.cc,
-                subject: _mMessage.subject,
-                html: _mMessage.html,
-                text: _mMessage.text,
-                headers: {
-                  'X-Laziness-level': 1000
-                }
-              };
-
-              if (_mMessage.MailAttachments) {
-                mail.attachments = _.map(_mMessage.MailAttachments, function (elm) {
-                  return {
-                    path: elm.path
-                  }
-                });
-              }
-
-              return new Promise(function (resolve, reject) {
-                _smtp.sendMail(mail, function (err, info) {
-                  if (err) {
-                    return reject(err);
-                  } else {
-                    resolve(info);
-                  }
-                });
-              });
-            })
-            .then(function (info) {
-              return _mMessage
-                .update({
-                  messageId: info.messageId,
-                  status: 'SENT'
-                }, {
-                  transaction: options ? options.transaction : null
-                });
-            });
-        } else {
-          return MailRoom
-            .findOrCreate({
-              where: {
-                id: _mMessage.MailRoomId
-              },
-              defaults: {
-                subject: _mMessage.subject,
-                from: _mMessage.from,
-                status: 'OPEN',
-                MailAccountId: _doc.MailAccountId
-              },
-              transaction: options ? options.transaction : null
-            })
-            .spread(function (mailRoom) {
-              _mRoom = mailRoom;
-              return mailRoom
-                .addMailMessage(_mMessage, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              return ContactEmail
-                .findOrCreate({
-                  where: {
-                    email: _mMessage.from
-                  },
-                  defaults: {
-                    email: _mMessage.from,
-                  },
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .spread(function (mFrom) {
-              var promises = [];
-              var tos = _mMessage.to ? _mMessage.to.split(';') : [];
-              _mFrom = mFrom;
-
-              tos.forEach(function (email) {
-                promises.push(ContactEmail
-                  .findOrCreate({
-                    where: {
-                      email: email
-                    },
-                    defaults: {
-                      email: email
-                    },
-                    transaction: options ? options.transaction : null
-                  }));
-              });
-
-              return promises;
-            })
-            .all()
-            .then(function (mTo) {
-              var promises = [];
-              var ccs = _mMessage.cc ? _mMessage.cc.split(';') : [];
-              _mTo = _.map(mTo, function (elm) {
-                return elm[0];
-              });
-
-              ccs.forEach(function (email) {
-                promises.push(ContactEmail
-                  .findOrCreate({
-                    where: {
-                      email: email
-                    },
-                    defaults: {
-                      email: email
-                    },
-                    transaction: options ? options.transaction : null
-                  }));
-              });
-
-              return promises;
-            })
-            .all()
-            .then(function (mCc) {
-              var promises = [];
-              var bccs = _mMessage.bcc ? _mMessage.bcc.split(';') : [];
-              _mCc = _.map(mCc, function (elm) {
-                return elm[0];
-              });
-
-              bccs.forEach(function (email) {
-                promises.push(ContactEmail
-                  .findOrCreate({
-                    where: {
-                      email: email
-                    },
-                    defaults: {
-                      email: email
-                    },
-                    transaction: options ? options.transaction : null
-                  }));
-              });
-
-              return promises;
-            })
-            .all()
-            .then(function (mBcc) {
-              _mBcc = _.map(mBcc, function (elm) {
-                return elm[0];
-              });
-
-              return;
-            })
-            .then(function () {
-              return _mMessage
-                .setFrom(_mFrom, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              return _mMessage
-                .setTo(_mTo, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              return _mMessage
-                .setCc(_mCc, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              return _mMessage
-                .setBcc(_mBcc, {
-                  transaction: options ? options.transaction : null
-                });
-            })
-            .then(function () {
-              var mail = {
-                status: _mMessage.status,
-                from: _mMessage.from,
-                to: _mMessage.to,
-                cc: _mMessage.cc,
-                subject: _mMessage.subject,
-                html: _mMessage.html,
-                text: _mMessage.text,
-                headers: {
-                  'X-Laziness-level': 1000
-                }
-              };
-
-              if (_mMessage.MailAttachments) {
-                mail.attachments = _.map(_mMessage.MailAttachments, function (elm) {
-                  return {
-                    path: elm.path
-                  }
-                });
-              }
-
-              return new Promise(function (resolve, reject) {
-                _smtp.sendMail(mail, function (err, info) {
-                  if (err) {
-                    return reject(err);
-                  } else {
-                    resolve(info);
-                  }
-                });
-              });
-            })
-            .then(function (info) {
-              return _mMessage
-                .update({
-                  messageId: info.messageId,
-                  status: 'SENT'
-                }, {
-                  transaction: options ? options.transaction : null
-                });
-            });
-        }
-      }
-    }
-
-    onSave(doc);
-
-    // HANDLE ACCOUNT UPDATE/DELETE
-    MailServerOut.afterUpdate(function (doc) {
-      onUpdate(doc);
-    });
-    MailServerOut.afterDestroy(function (doc) {
-      onRemove(doc);
-    });
-    // HANDLE SEND MAIL
-    MailMessage.afterCreate(function (doc, options) {
-      return onSend(doc, options);
-    });
-    // HANDLE SEND MAIL
-    // MailMessage.afterUpdate(function (doc) {
-    //   // onSend(doc);
-    // });
-  }
-};
\ No newline at end of file
diff --git a/server/config/socketio.js b/server/config/socketio.js
index 0d12443..66ace9d 100644
--- a/server/config/socketio.js
+++ b/server/config/socketio.js
@@ -1,195 +1 @@
-/**
- * Socket.io configuration
- */
-
-'use strict';
-
-var moment = require('moment');
-var config = require('./environment');
-var User = require('../models').User;
-
-function onDisconnect(socket) {
-  if (socket.userId) {
-    return User
-      .findById(socket.userId)
-      .then(function(user) {
-        if (user) {
-          return user
-            .updateAttributes({
-              online: false
-            });
-        } else {
-          throw new Error('socket: anyone users found');
-        }
-      })
-      .then(function(user) {
-        console.log('socket: user offline', user.name);
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  } else {
-    console.log('socket: anyone users found');
-  }
-}
-
-function onConnect(socket) {
-  if (socket.userId) {
-    return User
-      .findById(socket.userId)
-      .then(function(user) {
-        if (user) {
-          return user
-            .updateAttributes({
-              online: true,
-              lastLoginAt: moment().format("YYYY-MM-DD HH:mm:ss")
-            })
-        } else {
-          throw new Error('socket: anyone users found');
-        }
-      })
-      .then(function(user) {
-        console.log('socket: user online', user.name);
-
-        // Insert sockets below
-
-        //Ordered alphabetically
-        require('../api/agent/agent.socket').register(socket);
-        require('../api/ami/ami.socket').register(socket);
-        require('../api/automation/automation.socket').register(socket);
-        require('../api/business_action/business_action.socket').register(socket);
-        require('../api/business_condition/business_condition.socket').register(socket);
-        require('../api/chat_application/chat_application.socket').register(socket);
-        require('../api/chat_enquiry/enquiry.socket').register(socket);
-        require('../api/chat_message/chat_message.socket').register(socket);
-        require('../api/chat_queue/chat_queue.socket').register(socket);
-        require('../api/chat_room/chat_room.socket').register(socket);
-        require('../api/chat_visitor/chat_visitor.socket').register(socket);
-        require('../api/chat_website/chat_website.socket').register(socket);
-        require('../api/company/company.socket').register(socket);
-        require('../api/contact/contact.socket').register(socket);
-        require('../api/contact_manager/contact_manager.socket').register(socket);
-        require('../api/custom_field/custom_field.socket').register(socket);
-        require('../api/dashboard/dashboard.socket').register(socket);
-        require('../api/desk_account/desk_account.socket').register(socket);
-        require('../api/desk_configuration/desk_configuration.socket').register(socket);
-        require('../api/desk_field/desk_field.socket').register(socket);
-        require('../api/event/event.socket').register(socket);
-        require('../api/fax_account/fax_account.socket').register(socket);
-        require('../api/fax_application/fax_application.socket').register(socket);
-        require('../api/fax_business_automation/fax_business_automation.socket').register(socket);
-        require('../api/fax_message/fax_message.socket').register(socket);
-        require('../api/fax_queue/fax_queue.socket').register(socket);
-        require('../api/fax_room/fax_room.socket').register(socket);
-        require('../api/freshdesk_account/freshdesk_account.socket').register(socket);
-        require('../api/freshdesk_configuration/freshdesk_configuration.socket').register(socket);
-        require('../api/freshdesk_field/freshdesk_field.socket').register(socket);
-        require('../api/integration/integration.socket').register(socket);
-        require('../api/interval/interval.socket').register(socket);
-        require('../api/mail_account/mail_account.socket').register(socket);
-        require('../api/mail_application/mail_application.socket').register(socket);
-        require('../api/mail_attachment/mail_attachment.socket').register(socket);
-        require('../api/mail_business_automation/mail_business_automation.socket').register(socket);
-        require('../api/mail_message/mail_message.socket').register(socket);
-        require('../api/mail_queue/mail_queue.socket').register(socket);
-        require('../api/mail_room/mail_room.socket').register(socket);
-        require('../api/mail_server_in/mail_server_in.socket').register(socket);
-        require('../api/mail_template/mail_template.socket').register(socket);
-        require('../api/module/module.socket').register(socket);
-        require('../api/motionbar/motionbar.socket').register(socket);
-        require('../api/default_report/default_report.socket').register(socket);
-        require('../api/custom_report/custom_report.socket').register(socket);
-        require('../api/report_tree/report_tree.socket').register(socket);
-        require('../api/report_agent/report_agent.socket').register(socket);
-        require('../api/report_chat/report_chat.socket').register(socket);
-        require('../api/report_chat_session/report_chat_session.socket').register(socket);
-        require('../api/report_integration/report_integration.socket').register(socket);
-        require('../api/report_mail/report_mail.socket').register(socket);
-        require('../api/report_mail_session/report_mail_session.socket').register(socket);
-        require('../api/report_queue/report_queue.socket').register(socket);
-        require('../api/salesforce_account/salesforce_account.socket').register(socket);
-        require('../api/salesforce_configuration/salesforce_configuration.socket').register(socket);
-        require('../api/salesforce_field/salesforce_field.socket').register(socket);
-        require('../api/setting/setting.socket').register(socket);
-        require('../api/square_odbc/square_odbc.socket').register(socket);
-        require('../api/square_project/square_project.socket').register(socket);
-        require('../api/sugarcrm_account/sugarcrm_account.socket').register(socket);
-        require('../api/sugarcrm_configuration/sugarcrm_configuration.socket').register(socket);
-        require('../api/sugarcrm_field/sugarcrm_field.socket').register(socket);
-        require('../api/tag/tag.socket').register(socket);
-        require('../api/team/team.socket.js').register(socket);
-        require('../api/trigger/trigger.socket').register(socket);
-        require('../api/trunk/trunk.socket').register(socket);
-        require('../api/user/user.socket').register(socket);
-        require('../api/update/update.socket').register(socket);
-        require('../api/upload/upload.socket').register(socket);
-        require('../api/user_has_chat_queue/user_has_chat_queue.socket').register(socket);
-        require('../api/user_has_chat_room/user_has_chat_room.socket').register(socket);
-        require('../api/user_has_fax_queue/user_has_fax_queue.socket').register(socket);
-        require('../api/user_has_mail_queue/user_has_mail_queue.socket').register(socket);
-        require('../api/user_has_team/user_has_team.socket').register(socket);
-        require('../api/user_has_voice_queue/user_has_voice_queue.socket').register(socket);
-        require('../api/variable/variable.socket').register(socket);
-        require('../api/metric/metric.socket').register(socket);
-        require('../api/voice_context/voice_context.socket').register(socket);
-        require('../api/voice_extension/voice_extension.socket').register(socket);
-        require('../api/voice_musiconhold/voice_musiconhold.socket').register(socket);
-        require('../api/voice_queue/voice_queue.socket').register(socket);
-        require('../api/voice_voicemail/voice_voicemail.socket').register(socket);
-        require('../api/xchatty/xchatty.socket').register(socket);
-        require('../api/zendesk_account/zendesk_account.socket').register(socket);
-        require('../api/zendesk_configuration/zendesk_configuration.socket').register(socket);
-        require('../api/zendesk_field/zendesk_field.socket').register(socket);
-
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  } else {
-    console.log('socket: anyone users found');
-  }
-
-  socket.on('info', function(data) {
-    console.info('[%s] %s', socket.address, JSON.stringify(data, null, 2));
-  });
-
-}
-
-module.exports = function(socketio) {
-  // socket.io (v1.x.x) is powered by debug.
-  // In order to see all the debug output, set DEBUG (in server/config/local.env.js) to including the desired scope.
-  //
-  // ex: DEBUG: "http*,socket.io:socket"
-
-  // We can authenticate socket.io users and access their token through socket.handshake.decoded_token
-  //
-  // 1. You will need to send the token in `client/components/socket/socket.service.js`
-  //
-  // 2. Require authentication here:
-  socketio.use(require('socketio-jwt').authorize({
-    secret: config.session.secret,
-    handshake: true
-  }));
-
-  socketio.on('connection', function(socket) {
-    socket.address = socket.handshake.address !== null ? socket.handshake
-      .address.address + ':' + socket.handshake.address.port : process.env
-      .DOMAIN;
-
-    socket.connectedAt = new Date();
-    socket.userId = socket.handshake.query.userId;
-    socket.role = socket.handshake.query.role;
-    socket.name = socket.handshake.query.name;
-    socket.source = socket.handshake.query.source;
-
-    // Call onDisconnect.
-    socket.on('disconnect', function() {
-      onDisconnect(socket);
-      console.info('[%s] SOCKET DISCONNECTED', socket.handshake.address);
-    });
-
-    // Call onConnect.
-    onConnect(socket);
-    console.info('[%s] SOCKET CONNECTED', socket.handshake.address);
-  });
-};
\ No newline at end of file
diff --git a/server/config/triggers/chat.js b/server/config/triggers/chat.js
index a96e72f..ef46229 100644
--- a/server/config/triggers/chat.js
+++ b/server/config/triggers/chat.js
@@ -1,71 +1 @@
-var _ = require('lodash');
-var Mustache = require('mustache');
-
-var sequelize = require('../../models').sequelize;
-var ChatEnquiry = require('../../models').ChatEnquiry;
-var MailMessage = require('../../models').MailMessage;
-var MailServerOut = require('../../models').MailServerOut;
-
-function Chat() {
-  console.log('Trigger Chat Initialization...');
-
-  ChatEnquiry.afterCreate(function (chatEnquiry, options) {
-    var _chatEnquiry = chatEnquiry;
-    var _chatWebsite;
-    var _mailServerOut;
-    var _offlineTemplate;
-
-    return chatEnquiry
-      .getChatWebsite()
-      .then(function (chatWebsite) {
-        _chatWebsite = chatWebsite;
-        _chatEnquiry.chatWebsite = _chatWebsite.name;
-        if (_chatWebsite && _chatWebsite.enquiry_forwarding && _chatWebsite.enquiry_forwarding_address) {
-          return _chatWebsite
-            .getOfflineTemplate();
-        } else {
-          throw new Error({
-            message: 'chatWebsite can\'t send offline messages via mail'
-          });
-        }
-      })
-      .then(function (offlineTemplate) {
-        _offlineTemplate = offlineTemplate;
-        if (_offlineTemplate) {
-          _offlineTemplate.html = Mustache.render(_offlineTemplate.html, _chatEnquiry);
-          _offlineTemplate.subject = Mustache.render(_offlineTemplate.subject, _chatEnquiry);
-        } else {
-          throw new Error({
-            message: 'offlineTemplate not found. ChatWebsite: ' + _chatWebsite.name
-          });
-        }
-
-        return MailServerOut
-          .findOne({
-            where: {
-              service: true
-            }
-          });
-      })
-      .then(function (mailServerOut) {
-        _mailServerOut = mailServerOut;
-
-        if (!_mailServerOut) {
-          throw new Error('Motion Service SMTP not configured!');
-        }
-
-        return MailMessage
-          .create({
-            from: _mailServerOut.username,
-            to: _chatWebsite.enquiry_forwarding_address,
-            subject: _offlineTemplate.subject,
-            html: _offlineTemplate.html,
-            status: 'SENDING'
-          }, {
-            transaction: options ? options.transaction : null
-          });
-      });
-  });
-}
-
-module.exports = Chat;
\ No newline at end of file
diff --git a/server/config/triggers/cm.js b/server/config/triggers/cm.js
index ecd621e..0156383 100644
--- a/server/config/triggers/cm.js
+++ b/server/config/triggers/cm.js
@@ -1,68 +1 @@
-var _ = require('lodash');
-
-function Cm() {
-  console.log('Trigger Cm Initialization...');
-}
-
-Cm.prototype.manageContact = function(doc, channel) {
-  manageContact(doc, channel);
-}
-
-function manageContact(doc, channel) {
-  var Contact = require('../../models').Contact;
-  var ContactPhone = require('../../models').ContactPhone;
-  var ContactEmail = require('../../models').ContactEmail;
-  var ReportIntegration = require('../../models').ReportIntegration;
-  delete doc.id
-  doc.integration = 'contactmanager';
-  var modelInclude = {};
-  switch (channel) {
-    case 'voice':
-      modelInclude = {
-        model: ContactPhone,
-        as: 'Phones',
-        where: {
-          phone: doc.calleridnum
-        }
-      };
-      break;
-    case 'mail':
-      modelInclude = {
-        model: ContactEmail,
-        as: 'Emails',
-        where: {
-          email: doc.from
-        }
-      };
-      break;
-    default:
-  }
-  console.log('CM triggered by ' + channel + ' channel, finding contact...');
-  Contact.findAll({
-      include: [modelInclude]
-    })
-    .then(function(contacts) {
-      if (contacts.length) {
-        console.log('Found contact, open_contact row in report_integrations table...');
-        doc.event = 'openContactTab';
-        doc.contacts = JSON.stringify(_.map(_.pluck(contacts, 'dataValues'), function(elem) {
-          return {
-            id: elem.id,
-            name: elem.fullname
-          }
-        }));
-      } else {
-        console.log('Contact not found, new_contact tab row in report_integrations table...');
-        doc.event = 'newContactTab';
-      }
-      ReportIntegration.create(doc)
-        .catch(function(err) {
-          console.log(err);
-        });
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
-
-module.exports = Cm;
\ No newline at end of file
diff --git a/server/config/triggers/index.js b/server/config/triggers/index.js
index 80cbe70..9657cc0 100644
--- a/server/config/triggers/index.js
+++ b/server/config/triggers/index.js
@@ -1,97 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var Util = require('./util');
-var Voice = require('./voice');
-var Mail = require('./mail');
-var Chat = require('./chat');
-var Cm = require('./cm');
-var Trigger = require('../../models').Trigger;
-var ReportAgent = require('../../models').ReportAgent;
-var MailMessage = require('../../models').MailMessage;
-
-module.exports = function () {
-
-  var util = new Util();
-  var voice = new Voice();
-  var chat = new Chat();
-  var mail = new Mail();
-  var cm = new Cm();
-
-  Trigger
-    .findAll()
-    .then(function (triggers) {
-      synchTriggers(triggers);
-      console.log('Triggers are ', triggers.length);
-      ReportAgent.afterCreate(function (doc) {
-        var actions = util.getActionsByTriggers(doc, _.filter(triggers, {
-          channel: 'voice'
-        }));
-        console.log('After agent create, Actions are ', actions.length);
-        execActions(actions, doc, 'voice', util, voice, mail, cm);
-      })
-      ReportAgent.afterUpdate(function (doc) {
-        var actions = util.getActionsByTriggers(doc, _.filter(triggers, {
-          channel: 'voice'
-        }));
-        console.log('After agent update, Actions are ', actions.length);
-        execActions(actions, doc, 'voice', util, voice, mail, cm);
-      })
-      MailMessage.afterCreate(function (doc) {
-        if (doc.status === 'RECEIVED') {
-          var actions = util.getActionsByTriggers(doc, _.filter(triggers, {
-            channel: 'mail'
-          }));
-          execActions(actions, doc, 'mail', util, voice, mail, cm);
-        }
-      })
-    })
-    .catch(function (err) {
-      console.error(err);
-    });
-}
-
-
-function execActions(actions, doc, channel, util, voice, mail, cm) {
-  actions.forEach(function (rule) {
-    console.log('Executing action "' + rule.field.value + '"');
-    switch (rule.field.value) {
-    case 'contactManager':
-      cm.manageContact(doc.dataValues, channel);
-      break;
-    case 'template':
-      mail.sendTemplate(rule.data, rule.data2);
-      break;
-    default:
-    }
-  });
-}
-
-function synchTriggers(triggers) {
-  Trigger.afterCreate(function (doc) {
-    updateCollection(triggers, doc);
-    console.log('After create, Triggers are ', triggers.length);
-  });
-  Trigger.afterUpdate(function (doc) {
-    updateCollection(triggers, doc);
-    console.log('After update, Triggers are ', triggers.length);
-  });
-  Trigger.afterDestroy(function (doc) {
-    _.remove(triggers, {
-      id: doc.id
-    });
-    console.log('After destroy, Triggers are ', triggers.length);
-  });
-}
-
-function updateCollection(collection, doc) {
-  var oldItem = _.find(collection, {
-    id: doc.id
-  });
-  var index = collection.indexOf(oldItem);
-  if (oldItem) {
-    _.merge(collection[index], doc);
-  } else {
-    collection.unshift(doc);
-  }
-}
\ No newline at end of file
diff --git a/server/config/triggers/mail.js b/server/config/triggers/mail.js
index 243222f..8e81659 100644
--- a/server/config/triggers/mail.js
+++ b/server/config/triggers/mail.js
@@ -1,48 +1 @@
-var _ = require('lodash');
-
-function Mail() {
-  console.log('Trigger Mail Initialization...');
-}
-
-Mail.prototype.sendTemplate = function(templateId) {
-  sendTemplate(templateId);
-}
-
-function sendTemplate(templateId, smtpUser) {
-  var sequelize = require('../../models').sequelize;
-  var MailTemplate = require('../../models').MailTemplate;
-  var MailMessage = require('../../models').MailMessage;
-  var smtpInstances = require('../smtp').instances;
-  MailTemplate
-    .findById(templateId, {
-      include: [{
-        all: true
-      }]
-    })
-    .then(function(mailTemplate) {
-      // console.log('found template');
-      MailMessage
-        .create({
-          status: 'SENDING',
-          subject: mailTemplate.subject,
-          from: mailTemplate.from,
-          to: mailTemplate.to,
-          cc: mailTemplate.cc || '',
-          html: mailTemplate.html || null,
-          text: mailTemplate.text || null
-        })
-        .then(function(mailmessage) {
-          var smtp = _.find(smtpInstances, {
-            user: smtpUser
-          });
-          if (smtp) {
-            smtp.smtp.send(mailmessage);
-          }
-        })
-        .catch(function(err) {
-          console.log(err);
-        });
-    });
-}
-
-module.exports = Mail;
\ No newline at end of file
diff --git a/server/config/triggers/util.js b/server/config/triggers/util.js
index d2982b0..d45f577 100644
--- a/server/config/triggers/util.js
+++ b/server/config/triggers/util.js
@@ -1,97 +1 @@
-var _ = require('lodash');
-
-function Util() {
-  console.log('Trigger Utils Initialization...');
-}
-
-Util.prototype.getActionsByTriggers = function(doc, triggers) {
-  var actions = [];
-  doc.dataValues.from = doc.dataValues.from ? doc.dataValues.from.split(';') : [];
-  doc.dataValues.cc = doc.dataValues.cc ? doc.dataValues.cc.split(';') : [];
-  doc.dataValues.to = doc.dataValues.to ? doc.dataValues.to.split(';') : [];
-  triggers.forEach(function(trigger) {
-    if (trigger.status) {
-      var conditions = {
-        op: null,
-        results: [],
-        subGroups: []
-      };
-
-      var conditionsGroup = JSON.parse(trigger.conditions).group;
-      // console.log(JSON.stringify(conditionsGroup));
-      conditions.op = conditionsGroup.boolean;
-      conditionsGroup.rules.forEach(function(rule) {
-        if (rule.operator) {
-          // console.log('normal rule');
-          conditions.results.push(checkCondition(rule, doc.dataValues));
-        } else if (rule.group) {
-          // console.log('subgroup');
-          var subResults = [];
-          rule.group.rules.forEach(function(subrule) {
-            // console.log('subgroup rule');
-            subResults.push(checkCondition(subrule, doc.dataValues));
-          });
-          conditions.subGroups.push({
-            op: rule.group.boolean,
-            results: subResults
-          })
-        }
-      });
-      console.log(JSON.stringify(conditions));
-
-      var subResults = [],
-        lastResults = [];
-      conditions.subGroups.forEach(function(subElement) {
-        subResults.push(_.reduce(subElement.results.length ? subElement.results : [true], function(total, n) {
-          if (subElement.op === 'AND') {
-            return total && n;
-          } else {
-            return total || n;
-          }
-        }));
-      });
-      lastResults = conditions.results.concat(subResults);
-      var finalResult = _.reduce(lastResults.length ? lastResults : [true], function(total, n) {
-        if (conditions.op === 'AND') {
-          return total && n;
-        } else {
-          return total || n;
-        }
-      })
-      console.log('final result is', finalResult);
-
-      if (finalResult) {
-        //push rules into array to return
-        var actionsGroup = JSON.parse(trigger.actions).group;
-        actions = actions.concat(actionsGroup.rules);
-      }
-    }
-  });
-  doc.dataValues.from = doc.dataValues.from.join(';');
-  doc.dataValues.cc = doc.dataValues.cc.join(';');
-  doc.dataValues.to = doc.dataValues.to.join(';');
-  //return actions array
-  return actions;
-}
-
-function checkCondition(rule, doc) {
-  // console.log('trigger value ', trigger[rule.field.value]);
-  // console.log('rule data ', rule.data);
-  var result;
-  switch (rule.operator) {
-    case '=':
-      // console.log('is equal?');
-      result = _.includes(doc[rule.field.value], rule.data);
-      // console.log(result);
-      break;
-    case '<>':
-      // console.log('is not equal?');
-      result = !_.includes(doc[rule.field.value], rule.data);
-      // console.log(result);
-      break;
-    default:
-  }
-  return result;
-}
-
-module.exports = Util;
\ No newline at end of file
diff --git a/server/config/triggers/voice.js b/server/config/triggers/voice.js
index 2465c50..7344985 100644
--- a/server/config/triggers/voice.js
+++ b/server/config/triggers/voice.js
@@ -1,7 +1 @@
-var _ = require('lodash');
-
-function Voice() {
-  console.log('Trigger Voice Initialization...');
-}
-
-module.exports = Voice;
+var _0x7748=["\x6C\x6F\x64\x61\x73\x68","\x54\x72\x69\x67\x67\x65\x72\x20\x56\x6F\x69\x63\x65\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x65\x78\x70\x6F\x72\x74\x73"];var _=require(_0x7748[0]);function Voice(){console[_0x7748[2]](_0x7748[1])}module[_0x7748[3]]=Voice;
\ No newline at end of file
diff --git a/server/files/integrations/zendesk/app.js b/server/files/integrations/zendesk/app.js
index 524ce84..f927522 100644
--- a/server/files/integrations/zendesk/app.js
+++ b/server/files/integrations/zendesk/app.js
@@ -1,5 +1 @@
-'use strict';
-
-module.exports = function(io, ami) {
-  console.log('EXTERNAL APPLICATION');
-};
+var _0x383d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x45\x58\x54\x45\x52\x4E\x41\x4C\x20\x41\x50\x50\x4C\x49\x43\x41\x54\x49\x4F\x4E","\x6C\x6F\x67"];_0x383d[0];module[_0x383d[1]]=function(_0xb210x1,_0xb210x2){console[_0x383d[3]](_0x383d[2])};
\ No newline at end of file
diff --git a/server/migrations/20151202190300-test.js b/server/migrations/20151202190300-test.js
index b50913a..ef901e4 100644
--- a/server/migrations/20151202190300-test.js
+++ b/server/migrations/20151202190300-test.js
@@ -1,34 +1 @@
-'use strict';
-
-module.exports = {
-  up: function(queryInterface, Sequelize) {
-    /*
-      Add altering commands here.
-      Return a promise to correctly handle asynchronicity.
-
-      Example:
-      return queryInterface.createTable('users', { id: Sequelize.INTEGER });
-    */
-
-    return queryInterface
-      .addColumn(
-        'channels',
-        'testAttr', {
-          type: Sequelize.STRING
-        }
-      );
-  },
-
-  down: function(queryInterface, Sequelize) {
-    /*
-      Add reverting commands here.
-      Return a promise to correctly handle asynchronicity.
-
-      Example:
-      return queryInterface.dropTable('users');
-    */
-
-    return queryInterface
-      .removeColumn('channels', 'testAttr');
-  }
-};
\ No newline at end of file
diff --git a/server/models/asterisk_manager.js b/server/models/asterisk_manager.js
index 8cc071d..5b8466f 100644
--- a/server/models/asterisk_manager.js
+++ b/server/models/asterisk_manager.js
@@ -1,19 +1 @@
-/**
- * Asterisk Manager Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var AsteriskManager = sequelize.define('AsteriskManager', {
-    address: DataTypes.STRING,
-    port: DataTypes.INTEGER,
-    username: DataTypes.STRING,
-    password: DataTypes.STRING
-  }, {
-    tableName: 'asterisk_manager'
-  });
-
-  return AsteriskManager;
-};
\ No newline at end of file
diff --git a/server/models/asterisk_manager_interface.js b/server/models/asterisk_manager_interface.js
index 539add1..cd2df6b 100644
--- a/server/models/asterisk_manager_interface.js
+++ b/server/models/asterisk_manager_interface.js
@@ -1,24 +1 @@
-'use strict';
-
-/**
- * Asterisk Manager Interface Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Ami = sequelize.define('Ami', {
-    actionid: DataTypes.STRING,
-    action: DataTypes.STRING,
-    response: DataTypes.STRING,
-    message: DataTypes.STRING,
-    data: DataTypes.TEXT
-  }, {
-    tableName: 'asterisk_manager_interface',
-    associate: function(models) {
-      // USER RELATIONS
-      Ami.belongsTo(models.User);
-    }
-  });
-
-  return Ami;
-};
\ No newline at end of file
diff --git a/server/models/autodialer_contact.js b/server/models/autodialer_contact.js
index 0719b90..cadfa28 100644
--- a/server/models/autodialer_contact.js
+++ b/server/models/autodialer_contact.js
@@ -1,15 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var AutodialerContact = sequelize.define('AutodialerContact', {
-    status: {
-      type: DataTypes.STRING
-    }
-  }, {
-    tableName: 'autodialer_contacts'
-  });
-
-  return AutodialerContact;
-
-};
+var _0x1b63=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x41\x75\x74\x6F\x64\x69\x61\x6C\x65\x72\x43\x6F\x6E\x74\x61\x63\x74","\x53\x54\x52\x49\x4E\x47","\x61\x75\x74\x6F\x64\x69\x61\x6C\x65\x72\x5F\x63\x6F\x6E\x74\x61\x63\x74\x73","\x64\x65\x66\x69\x6E\x65"];_0x1b63[0];module[_0x1b63[1]]=function(_0xb414x1,_0xb414x2){var _0xb414x3=_0xb414x1[_0x1b63[5]](_0x1b63[2],{status:{type:_0xb414x2[_0x1b63[3]]}},{tableName:_0x1b63[4]});return _0xb414x3;};
\ No newline at end of file
diff --git a/server/models/autodialer_process.js b/server/models/autodialer_process.js
index 7ddc225..3c1b239 100644
--- a/server/models/autodialer_process.js
+++ b/server/models/autodialer_process.js
@@ -1,53 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var AutodialerProcess = sequelize.define('AutodialerProcess', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    description: {
-      type: DataTypes.STRING,
-    },
-    context: {
-        type: DataTypes.STRING,
-    },
-    extension: {
-        type: DataTypes.STRING,
-    },
-    priority: {
-        type: DataTypes.INTEGER,
-    },
-    callerid: {
-        type: DataTypes.STRING,
-    },
-    waittime: {
-        type: DataTypes.INTEGER,
-    },
-    maxretry: {
-        type: DataTypes.INTEGER,
-    },
-    retrytime: {
-        type: DataTypes.INTEGER,
-    },
-    prefix: {
-        type: DataTypes.STRING,
-    },
-    maxcall: {
-        type: DataTypes.INTEGER,
-    },
-    enable: {
-    type: DataTypes.BOOLEAN,
-    defaultValue: true
-    }
-  }, {
-    tableName: 'autodialer_processes',
-    associate: function(models) {
-        AutodialerProcess.belongsToMany(models.Contact, { through: models.AutodialerContact })
-    }
-  });
-
-  return AutodialerProcess;
-
-};
\ No newline at end of file
diff --git a/server/models/automation.js b/server/models/automation.js
index 380a161..d684a9f 100644
--- a/server/models/automation.js
+++ b/server/models/automation.js
@@ -1,24 +1 @@
-/**
- * User Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Automation = sequelize.define('Automation', {
-    name: DataTypes.STRING,
-    channel: DataTypes.STRING,
-    description: DataTypes.STRING,
-    conditions: DataTypes.TEXT,
-    actions: DataTypes.TEXT,
-    status: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    }
-  }, {
-    tableName: 'automations'
-  });
-
-  return Automation;
-};
\ No newline at end of file
diff --git a/server/models/business_action.js b/server/models/business_action.js
index 579300c..08db90d 100644
--- a/server/models/business_action.js
+++ b/server/models/business_action.js
@@ -1,29 +1 @@
-/**
- * User Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var BusinessAction = sequelize.define('BusinessAction', {
-    condition: {
-      type: DataTypes.STRING,
-    },
-    attribute: {
-      type: DataTypes.STRING,
-    }
-  }, {
-    tableName: 'business_actions',
-    associate: function(models) {
-      BusinessAction.belongsTo(models.MailBusinessAutomation, {
-        onDelete: 'cascade'
-      });
-      BusinessAction.belongsTo(models.FaxBusinessAutomation, {
-        onDelete: 'cascade'
-      });
-    }
-  });
-
-  return BusinessAction;
-};
\ No newline at end of file
diff --git a/server/models/business_condition.js b/server/models/business_condition.js
index a688ad3..3e47d29 100644
--- a/server/models/business_condition.js
+++ b/server/models/business_condition.js
@@ -1,35 +1 @@
-/**
- * User Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var BusinessCondition = sequelize.define('BusinessCondition', {
-    type: {
-      type: DataTypes.ENUM('or', 'and'),
-    },
-    condition: {
-      type: DataTypes.STRING,
-    },
-    operator: {
-      type: DataTypes.STRING,
-    },
-    attribute: {
-      type: DataTypes.STRING,
-    }
-  }, {
-    tableName: 'business_conditions',
-    associate: function(models) {
-      BusinessCondition.belongsTo(models.MailBusinessAutomation, {
-        onDelete: 'cascade'
-      });
-      BusinessCondition.belongsTo(models.FaxBusinessAutomation, {
-        onDelete: 'cascade'
-      });
-    }
-  });
-
-  return BusinessCondition;
-};
\ No newline at end of file
diff --git a/server/models/channel.js b/server/models/channel.js
index e1c6d79..ae5b8d3 100644
--- a/server/models/channel.js
+++ b/server/models/channel.js
@@ -1,46 +1 @@
-/**
- * Channel Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Channel = sequelize.define('Channel', {
-    name: {
-      type: DataTypes.STRING,
-      validate: {
-        isUnique: function(name, next) {
-          Channel
-            .find({
-              where: {
-                name: name
-              }
-            })
-            .done(function(error, channel) {
-              if (error)
-                next(error);
-
-              if (channel)
-                next({
-                  message: 'name already used'
-                });
-
-              next();
-            });
-        }
-      }
-    },
-    title: DataTypes.STRING,
-    link: DataTypes.STRING,
-    icon: DataTypes.STRING,
-    position: DataTypes.STRING
-  }, {
-    tableName: 'channels',
-    associate: function(models) {
-      Channel.belongsToMany(models.User, {
-        through: 'user_has_channels'
-      });
-    }
-  });
-
-  return Channel;
-};
\ No newline at end of file
diff --git a/server/models/chat_application.js b/server/models/chat_application.js
index e0789ff..6c20f1f 100644
--- a/server/models/chat_application.js
+++ b/server/models/chat_application.js
@@ -1,30 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ChatApplication = sequelize.define('ChatApplication', {
-    app: {
-      type: DataTypes.ENUM('queue', 'agent')
-    },
-    priority: {
-      type: DataTypes.INTEGER
-    },
-    timeout: {
-      type: DataTypes.INTEGER
-    },
-    interval: {
-      type: DataTypes.STRING
-    }
-  }, {
-    tableName: 'chat_applications',
-    associate: function(models) {
-      // hasMany relations
-      ChatApplication.belongsTo(models.ChatWebsite);
-      ChatApplication.belongsTo(models.Interval);
-      ChatApplication.belongsTo(models.ChatQueue);
-      ChatApplication.belongsTo(models.User);
-    }
-  });
-
-  return ChatApplication;
-};
\ No newline at end of file
diff --git a/server/models/chat_enquiry.js b/server/models/chat_enquiry.js
index b61f03a..3f1660e 100644
--- a/server/models/chat_enquiry.js
+++ b/server/models/chat_enquiry.js
@@ -1,23 +1 @@
-'use strict';
-
-module.exports = function (sequelize, DataTypes) {
-
-  var ChatEnquiry = sequelize.define('ChatEnquiry', {
-    username: DataTypes.STRING,
-    email: DataTypes.STRING,
-    text: DataTypes.TEXT,
-    read: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    }
-  }, {
-    tableName: 'chat_enquiries',
-    associate: function (models) {
-      ChatEnquiry.belongsTo(models.ChatWebsite);
-      ChatEnquiry.belongsTo(models.ChatVisitor);
-    }
-  });
-
-  return ChatEnquiry;
-
-};
\ No newline at end of file
diff --git a/server/models/chat_message.js b/server/models/chat_message.js
index 4b6dff4..de6583d 100644
--- a/server/models/chat_message.js
+++ b/server/models/chat_message.js
@@ -1,25 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function (sequelize, DataTypes) {
-
-	var ChatMessage = sequelize.define('ChatMessage', {
-		body: {
-			type: DataTypes.TEXT,
-			notNull: true,
-			notEmpty: true,
-		}
-	}, {
-		tableName: 'chat_messages',
-		associate: function (models) {
-			ChatMessage.belongsTo(models.ChatRoom);
-			ChatMessage.belongsTo(models.ChatVisitor);
-			ChatMessage.belongsTo(models.User);
-		}
-	});
-
-	return ChatMessage;
-};
\ No newline at end of file
diff --git a/server/models/chat_queue.js b/server/models/chat_queue.js
index e8ed7f0..b2b709a 100644
--- a/server/models/chat_queue.js
+++ b/server/models/chat_queue.js
@@ -1,30 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ChatQueue = sequelize.define('ChatQueue', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    description: {
-      type: DataTypes.STRING,
-    },
-    timeout: {
-      type: DataTypes.INTEGER,
-    },
-    strategy: {
-      type: DataTypes.ENUM('rrmemory', 'beepall')
-    }
-  }, {
-    tableName: 'chat_queues',
-    associate: function(models) {
-      // hasMany relations
-      ChatQueue.belongsToMany(models.User, {
-        through: models.UserHasChatQueue
-      });
-    }
-  });
-
-  return ChatQueue;
-};
\ No newline at end of file
diff --git a/server/models/chat_room.js b/server/models/chat_room.js
index 55fcef7..5ea5fc2 100644
--- a/server/models/chat_room.js
+++ b/server/models/chat_room.js
@@ -1,38 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var ChatRoom = sequelize.define('ChatRoom', {
-		type: DataTypes.ENUM('internal', 'external'),
-		name: DataTypes.STRING,
-		token: {
-			type: DataTypes.STRING,
-			unique: true
-		},
-		// jobId: {
-		// 	type: DataTypes.INTEGER,
-		// 	unique: true
-		// },
-		status: {
-			type: DataTypes.ENUM('pending', 'open', 'close'),
-			defaultValue: 'pending'
-		},
-		// participants: DataTypes.TEXT
-	}, {
-		tableName: 'chat_rooms',
-		associate: function(models) {
-			ChatRoom.hasMany(models.ChatMessage);
-			ChatRoom.belongsTo(models.ChatVisitor);
-			ChatRoom.belongsTo(models.ChatWebsite);
-			ChatRoom.belongsToMany(models.User, {
-				through: models.UserHasChatRoom
-			});
-		}
-	});
-
-	return ChatRoom;
-};
\ No newline at end of file
diff --git a/server/models/chat_visitor.js b/server/models/chat_visitor.js
index 62bc49b..f9c91b6 100644
--- a/server/models/chat_visitor.js
+++ b/server/models/chat_visitor.js
@@ -1,40 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var ChatVisitor = sequelize.define('ChatVisitor', {
-		fullname: DataTypes.STRING,
-		email: DataTypes.STRING,
-		remote_address: DataTypes.STRING,
-		user_agent: DataTypes.STRING,
-		visitor_language: DataTypes.STRING,
-		referer: DataTypes.STRING,
-		browser: DataTypes.STRING,
-		engine: DataTypes.STRING,
-		os: DataTypes.STRING,
-		device: DataTypes.STRING,
-		country: DataTypes.STRING,
-		region: DataTypes.STRING,
-		city: DataTypes.STRING,
-		latitude: DataTypes.STRING,
-		longitude: DataTypes.STRING,
-		origin: DataTypes.ENUM('webchat', 'enquiry'),
-		status: {
-			type: DataTypes.ENUM('pending', 'unserved', 'served'),
-			defaultValue: 'pending'
-		}
-	}, {
-		tableName: 'chat_visitors',
-		associate: function(models) {
-			ChatVisitor.hasMany(models.ChatMessage);
-			ChatVisitor.hasMany(models.ChatRoom);
-			ChatVisitor.belongsTo(models.ChatWebsite);
-		}
-	});
-
-	return ChatVisitor;
-};
\ No newline at end of file
diff --git a/server/models/chat_website.js b/server/models/chat_website.js
index 862e0e7..dbfa07a 100644
--- a/server/models/chat_website.js
+++ b/server/models/chat_website.js
@@ -1,97 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function (sequelize, DataTypes) {
-
-	var ChatWebsite = sequelize.define('ChatWebsite', {
-		name: DataTypes.STRING,
-		address: {
-			type: DataTypes.STRING,
-			unique: true
-		},
-		description: DataTypes.STRING,
-		color: {
-			type: DataTypes.STRING,
-			defaultValue: '#000080'
-		},
-		color_focus: {
-			type: DataTypes.STRING,
-			defaultValue: '#000080'
-		},
-		color_button: {
-			type: DataTypes.STRING,
-			defaultValue: '#000080'
-		},
-		remote: DataTypes.STRING,
-		animation: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: true
-		},
-		header_shape: {
-			type: DataTypes.ENUM('rounded', 'squared'),
-			defaultValue: 'rounded'
-		},
-		header_online: {
-			type: DataTypes.STRING,
-			defaultValue: 'We are here!'
-		},
-		online_message: {
-			type: DataTypes.STRING,
-			defaultValue: '<strong>Questions?<\/strong><br \/>Insert your name and email address to start a live-chat with our support team.'
-		},
-		username_placeholder: {
-			type: DataTypes.STRING,
-			defaultValue: 'Your name'
-		},
-		email_placeholder: {
-			type: DataTypes.STRING,
-			defaultValue: 'Your e-mail address'
-		},
-		start_chat_button: {
-			type: DataTypes.STRING,
-			defaultValue: 'Chat'
-		},
-		header_offline: {
-			type: DataTypes.STRING,
-			defaultValue: 'Contact us'
-		},
-		offline_message: {
-			type: DataTypes.STRING,
-			defaultValue: '<strong>We\'re not online.<\/strong><br \/>It doesn\'t mean we\'re not there to help - leave your message below and we\'ll be in touch as soon as possible.'
-		},
-		enquiry_message_placeholder: {
-			type: DataTypes.STRING,
-			defaultValue: 'Your message...'
-		},
-		enquiry_button: {
-			type: DataTypes.STRING,
-			defaultValue: 'Leave message'
-		},
-		download_transcript: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: true
-		},
-		enquiry_forwarding: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		enquiry_forwarding_address: {
-			type: DataTypes.STRING
-		},
-	}, {
-		tableName: 'chat_websites',
-		associate: function (models) {
-			// hasMany relations
-			ChatWebsite.belongsTo(models.MailTemplate, {
-				as: 'OfflineTemplate'
-			});
-			ChatWebsite.hasMany(models.ChatRoom);
-			ChatWebsite.hasMany(models.ChatApplication);
-		}
-	});
-
-	return ChatWebsite;
-};
\ No newline at end of file
diff --git a/server/models/company.js b/server/models/company.js
index 12768bd..f886cd3 100644
--- a/server/models/company.js
+++ b/server/models/company.js
@@ -1,30 +1 @@
-/**
- * tag Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Company = sequelize.define('Company', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    street: DataTypes.STRING,
-    postalCode: DataTypes.STRING,
-    city: DataTypes.STRING,
-    country: DataTypes.STRING,
-    sStreet: DataTypes.STRING,
-    sPostalCode: DataTypes.STRING,
-    sCity: DataTypes.STRING,
-    sCountry: DataTypes.STRING,
-  }, {
-    tableName: 'companies',
-    associate: function(models) {
-      Company.hasMany(models.Contact, {
-        as: 'Contacts'
-      });
-    }
-  });
-
-  return Company;
-};
\ No newline at end of file
diff --git a/server/models/contact.js b/server/models/contact.js
index 288b512..cd5fd0c 100644
--- a/server/models/contact.js
+++ b/server/models/contact.js
@@ -1,43 +1 @@
-/**
- * Contact Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Contact = sequelize.define('Contact', {
-    fullname: {
-      type: DataTypes.STRING,
-      validate: {
-        notEmpty: true
-      }
-    },
-    tags: DataTypes.STRING,
-    // CompanyId: DataTypes.STRING,/Da creare con l' associazione
-    street: DataTypes.STRING,
-    postalCode: DataTypes.STRING,
-    city: DataTypes.STRING,
-    country: DataTypes.STRING,
-    dateOfBirth: DataTypes.STRING,
-    description: DataTypes.STRING
-  }, {
-    tableName: 'contacts',
-    associate: function(models) {
-      Contact.belongsToMany(models.ContactPhone, {
-        through: 'contact_has_phones',
-        as: 'Phones'
-      });
-      Contact.belongsToMany(models.ContactEmail, {
-        through: 'contact_has_emails',
-        as: 'Emails'
-      });
-      Contact.belongsToMany(models.CustomField, {
-        through: models.ContactHasCustomField,
-        as: 'CustomFields'
-      });
-      Contact.belongsTo(models.Company);
-      Contact.belongsTo(models.User);
-    }
-  });
-
-  return Contact;
-};
\ No newline at end of file
diff --git a/server/models/contact_email.js b/server/models/contact_email.js
index d20827c..a18b35b 100644
--- a/server/models/contact_email.js
+++ b/server/models/contact_email.js
@@ -1,32 +1 @@
-/**
- * Contact Model
- */
-
-module.exports = function (sequelize, DataTypes) {
-
-  var ContactEmail = sequelize.define('ContactEmail', {
-    email: {
-      type: DataTypes.STRING,
-      primaryKey: true
-    }
-  }, {
-    tableName: 'contact_emails',
-    associate: function (models) {
-      ContactEmail.belongsToMany(models.Contact, {
-        through: 'contact_has_emails'
-      });
-      ContactEmail.hasMany(models.ReportMailSession, {
-        as: 'InboundMessages',
-        foreignKey: 'from',
-        constraints: false
-      });
-      ContactEmail.hasMany(models.ReportMailSession, {
-        as: 'OutboundMessages',
-        foreignKey: 'to',
-        constraints: false
-      });
-    }
-  });
-
-  return ContactEmail;
-};
\ No newline at end of file
diff --git a/server/models/contact_has_custom_field.js b/server/models/contact_has_custom_field.js
index 650b530..8e57f1f 100644
--- a/server/models/contact_has_custom_field.js
+++ b/server/models/contact_has_custom_field.js
@@ -1,16 +1 @@
-/**
- * contact has customfield Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var ContactHasCustomField = sequelize.define('ContactHasCustomField', {
-		value: DataTypes.STRING
-	}, {
-		tableName: 'contact_has_custom_fields'
-	});
-
-	return ContactHasCustomField;
-};
\ No newline at end of file
diff --git a/server/models/contact_phone.js b/server/models/contact_phone.js
index 08d704f..84b8e2e 100644
--- a/server/models/contact_phone.js
+++ b/server/models/contact_phone.js
@@ -1,32 +1 @@
-/**
- * Contact Model
- */
-
-module.exports = function (sequelize, DataTypes) {
-
-  var ContactPhone = sequelize.define('ContactPhone', {
-    phone: {
-      type: DataTypes.STRING,
-      primaryKey: true
-    }
-  }, {
-    tableName: 'contact_phones',
-    associate: function (models) {
-      ContactPhone.belongsToMany(models.Contact, {
-        through: 'contact_has_phones'
-      });
-      ContactPhone.hasMany(models.ReportCall, {
-        as: 'Inbounds',
-        foreignKey: 'source',
-        constraints: false
-      });
-      ContactPhone.hasMany(models.ReportCall, {
-        as: 'Outbounds',
-        foreignKey: 'destination',
-        constraints: false
-      });
-    }
-  });
-
-  return ContactPhone;
-};
\ No newline at end of file
diff --git a/server/models/custom_field.js b/server/models/custom_field.js
index ae475b0..d77bd8a 100644
--- a/server/models/custom_field.js
+++ b/server/models/custom_field.js
@@ -1,28 +1 @@
-/**
- * customfield Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var CustomField = sequelize.define('CustomField', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    type: DataTypes.STRING,
-    active: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    },
-    values: DataTypes.STRING
-  }, {
-    tableName: 'contact_custom_fields',
-    associate: function(models) {
-      CustomField.belongsToMany(models.Contact, {
-        through: models.ContactHasCustomField
-      });
-    }
-  });
-
-  return CustomField;
-};
\ No newline at end of file
diff --git a/server/models/custom_report.js b/server/models/custom_report.js
index 2e35e9a..8d55f98 100644
--- a/server/models/custom_report.js
+++ b/server/models/custom_report.js
@@ -1,14 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var CustomReport = sequelize.define('CustomReport', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING,
-    parent: DataTypes.STRING
-  }, {
-    tableName: 'custom_reports'
-  });
-
-  return CustomReport;
-};
+var _0xd60e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x43\x75\x73\x74\x6F\x6D\x52\x65\x70\x6F\x72\x74","\x53\x54\x52\x49\x4E\x47","\x63\x75\x73\x74\x6F\x6D\x5F\x72\x65\x70\x6F\x72\x74\x73","\x64\x65\x66\x69\x6E\x65"];_0xd60e[0];module[_0xd60e[1]]=function(_0xe35dx1,_0xe35dx2){var _0xe35dx3=_0xe35dx1[_0xd60e[5]](_0xd60e[2],{name:_0xe35dx2[_0xd60e[3]],description:_0xe35dx2[_0xd60e[3]],parent:_0xe35dx2[_0xd60e[3]]},{tableName:_0xd60e[4]});return _0xe35dx3;};
\ No newline at end of file
diff --git a/server/models/dashboard.js b/server/models/dashboard.js
index 254f702..ed1be2d 100644
--- a/server/models/dashboard.js
+++ b/server/models/dashboard.js
@@ -1,62 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Dashboard = sequelize.define('Dashboard', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    description: {
-      type: DataTypes.STRING,
-    },
-    model: {
-      type: DataTypes.TEXT,
-    },
-    collapsible: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    },
-    editable: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    },
-    maximizable: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    },
-    structure: {
-      type: DataTypes.STRING(32),
-      defaultValue: '4-8'
-    },
-    enableconfirmdelete: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    },
-    defaultEntry: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: 0
-    },
-    admin: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    },
-    user: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    },
-    agent: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    },
-    visible: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    }
-  }, {
-    tableName: 'dashboards'
-  });
-
-  return Dashboard;
-
-};
\ No newline at end of file
diff --git a/server/models/default_report.js b/server/models/default_report.js
index 4abe87d..317f43a 100644
--- a/server/models/default_report.js
+++ b/server/models/default_report.js
@@ -1,14 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var DefaultReport = sequelize.define('DefaultReport', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING,
-    parent: DataTypes.STRING
-  }, {
-    tableName: 'default_reports'
-  });
-
-  return DefaultReport;
-};
\ No newline at end of file
diff --git a/server/models/desk_account.js b/server/models/desk_account.js
index 57562ca..bb01e05 100644
--- a/server/models/desk_account.js
+++ b/server/models/desk_account.js
@@ -1,36 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var DeskAccount = sequelize.define('DeskAccount', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING,
-    username: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    remoteUri: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    authType: {
-      type: DataTypes.ENUM('basic', 'oauth'),
-      defaultValue: 'basic'
-    },
-    password: DataTypes.STRING,
-    consumerKey: DataTypes.STRING,
-    consumerSecret: DataTypes.STRING,
-    token: DataTypes.STRING,
-    tokenSecret: DataTypes.STRING
-  }, {
-    tableName: 'desk_accounts',
-    associate: function(models) {
-      DeskAccount.hasMany(models.DeskConfiguration, {
-        foreignKey: 'AccountId'
-      });
-    }
-  });
-
-  return DeskAccount;
-
-};
\ No newline at end of file
diff --git a/server/models/desk_configuration.js b/server/models/desk_configuration.js
index fb92e7e..d3b86bf 100644
--- a/server/models/desk_configuration.js
+++ b/server/models/desk_configuration.js
@@ -1,27 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('DeskConfiguration', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING
-  }, {
-    tableName: 'desk_configurations',
-    associate: function(models) {
-      models.DeskConfiguration.belongsTo(models.DeskAccount, {
-        foreignKey: 'AccountId'
-      });
-      models.DeskConfiguration.hasMany(models.DeskField, {
-        as: 'Subject',
-        foreignKey: 'SubjectId'
-      });
-      models.DeskConfiguration.hasMany(models.DeskField, {
-        as: 'Description',
-        foreignKey: 'DescriptionId'
-      });
-      models.DeskConfiguration.hasMany(models.DeskField, {
-        as: 'Field',
-        foreignKey: 'FieldId'
-      });
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/desk_field.js b/server/models/desk_field.js
index befea49..07be821 100644
--- a/server/models/desk_field.js
+++ b/server/models/desk_field.js
@@ -1,26 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('DeskField', {
-    type: {
-      type: DataTypes.ENUM('string', 'variable', 'key_value'),
-      defaultValue: 'string'
-    },
-    content: DataTypes.STRING,
-    key: DataTypes.STRING,
-    keyType: {
-      type: DataTypes.ENUM('string', 'variable')
-    },
-    keyContent: DataTypes.STRING,
-    idField: DataTypes.STRING,
-    customField: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    }
-  }, {
-    tableName: 'desk_fields',
-    associate: function(models) {
-      models.DeskField.belongsTo(models.Variable);
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/event.js b/server/models/event.js
index fba2c1c..2ab54ad 100644
--- a/server/models/event.js
+++ b/server/models/event.js
@@ -1,45 +1 @@
-/**
- * Event Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-	var Event = sequelize.define('Event', {
-		name: {
-			type: DataTypes.ENUM('INCOMING', 'OUTGOING', 'ATTEMPT', 'ASSIGNED', 'UNASSIGNED')
-		},
-		channel: {
-			type: DataTypes.ENUM('MAIL', 'CHAT', 'FAX', 'VOICE'),
-		},
-		timeout: {
-			type: DataTypes.INTEGER
-		},
-		holdtime: {
-			type: DataTypes.INTEGER
-		}
-	}, {
-		tableName: 'events',
-		associate: function(models) {
-			// USER RELATIONS
-			Event.belongsTo(models.User);
-			// MAIL RELATIONS
-			Event.belongsTo(models.MailRoom);
-			Event.belongsTo(models.MailMessage);
-			Event.belongsTo(models.MailQueue);
-			Event.belongsTo(models.MailAccount);
-			Event.belongsTo(models.MailApplication);
-			// FAX RELATIONS
-			Event.belongsTo(models.FaxRoom);
-			Event.belongsTo(models.FaxQueue);
-			Event.belongsTo(models.FaxAccount);
-			Event.belongsTo(models.FaxApplication);
-			// CHAT RELATIONS
-			Event.belongsTo(models.ChatRoom);
-			Event.belongsTo(models.ChatQueue);
-			Event.belongsTo(models.ChatWebsite);
-			Event.belongsTo(models.ChatApplication);
-		}
-	});
-
-	return Event;
-};
\ No newline at end of file
diff --git a/server/models/fax_account.js b/server/models/fax_account.js
index bb903c1..f54c491 100644
--- a/server/models/fax_account.js
+++ b/server/models/fax_account.js
@@ -1,40 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var FaxAccount = sequelize.define('FaxAccount', {
-		description: DataTypes.STRING,
-		name: DataTypes.STRING,
-		phone: {
-			type: DataTypes.STRING,
-			unique: true
-		},
-		ecm: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		faxheader: DataTypes.STRING,
-		localid: DataTypes.STRING,
-		maxrate: {
-			type: DataTypes.ENUM('9600', '14400', '33600'),
-			defaultValue: '33600'
-		},
-		minrate: {
-			type: DataTypes.ENUM('9600', '14400', '33600'),
-			defaultValue: '9600'
-		}
-	}, {
-		tableName: 'fax_accounts',
-		associate: function(models) {
-			FaxAccount.belongsTo(models.Trunk);
-			FaxAccount.hasMany(models.FaxRoom);
-			FaxAccount.hasMany(models.FaxApplication);
-		}
-	});
-
-	return FaxAccount;
-};
\ No newline at end of file
diff --git a/server/models/fax_application.js b/server/models/fax_application.js
index b4c6d10..0937edb 100644
--- a/server/models/fax_application.js
+++ b/server/models/fax_application.js
@@ -1,33 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var FaxApplication = sequelize.define('FaxApplication', {
-    app: {
-      type: DataTypes.ENUM('queue', 'agent')
-    },
-    appdata: {
-      type: DataTypes.INTEGER
-    },
-    priority: {
-      type: DataTypes.INTEGER
-    },
-    timeout: {
-      type: DataTypes.INTEGER
-    },
-    interval: {
-      type: DataTypes.STRING,
-      defaultValue: '*|*|*|*'
-    }
-  }, {
-    tableName: 'fax_applications',
-    associate: function(models) {
-      // hasMany relations
-      FaxApplication.belongsTo(models.FaxAccount);
-      FaxApplication.belongsTo(models.FaxQueue);
-      FaxApplication.belongsTo(models.User);
-    }
-  });
-
-  return FaxApplication;
-};
\ No newline at end of file
diff --git a/server/models/fax_business_automation.js b/server/models/fax_business_automation.js
index 75eb2a8..da9003c 100644
--- a/server/models/fax_business_automation.js
+++ b/server/models/fax_business_automation.js
@@ -1,32 +1 @@
-/**
- * User Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var FaxBusinessAutomation = sequelize.define('FaxBusinessAutomation', {
-    name: {
-      type: DataTypes.STRING
-    },
-    description: {
-      type: DataTypes.STRING
-    },
-    status: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    },
-    jobId: {
-      type: DataTypes.INTEGER
-    }
-  }, {
-    tableName: 'fax_business_automations',
-    associate: function(models) {
-      FaxBusinessAutomation.hasMany(models.BusinessAction);
-      FaxBusinessAutomation.hasMany(models.BusinessCondition);
-    }
-  });
-
-  return FaxBusinessAutomation;
-};
\ No newline at end of file
diff --git a/server/models/fax_message.js b/server/models/fax_message.js
index 78700ac..ef1b4e2 100644
--- a/server/models/fax_message.js
+++ b/server/models/fax_message.js
@@ -1,63 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var FaxMessage = sequelize.define('FaxMessage', {
-		actionid: DataTypes.STRING,
-		channel: DataTypes.STRING,
-		channelstate: DataTypes.INTEGER,
-		channelstatedesc: DataTypes.STRING,
-		calleridnum: DataTypes.STRING,
-		calleridname: DataTypes.STRING,
-		connectedlinenum: DataTypes.STRING,
-		connectedlinename: DataTypes.STRING,
-		status: {
-			type: DataTypes.ENUM('RECEIVED', 'NOT SENT', 'SENDING', 'SENT',
-				'FAILED'),
-			allowNull: true
-		},
-		read: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		favorite: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		language: DataTypes.STRING,
-		accountcode: DataTypes.STRING,
-		context: DataTypes.STRING,
-		exten: DataTypes.STRING,
-		priority: DataTypes.INTEGER,
-		uniqueid: DataTypes.STRING,
-		localstationid: DataTypes.STRING,
-		remotestationid: DataTypes.STRING,
-		pagestransferred: DataTypes.INTEGER,
-		resolution: DataTypes.STRING,
-		transferrate: DataTypes.STRING,
-		filename: DataTypes.STRING,
-		filenamePDF: DataTypes.STRING,
-		operation: DataTypes.STRING,
-		uuid: DataTypes.STRING,
-		laststatus: DataTypes.STRING,
-		error: DataTypes.STRING,
-		body: DataTypes.TEXT
-	}, {
-		tableName: 'fax_messages',
-		associate: function(models) {
-			FaxMessage.belongsTo(models.FaxRoom);
-			FaxMessage.belongsTo(models.Contact, {
-				as: 'From'
-			});
-			FaxMessage.belongsTo(models.Contact, {
-				as: 'To'
-			});
-		}
-	});
-
-	return FaxMessage;
-};
\ No newline at end of file
diff --git a/server/models/fax_queue.js b/server/models/fax_queue.js
index 3c2a6b0..e08ef6c 100644
--- a/server/models/fax_queue.js
+++ b/server/models/fax_queue.js
@@ -1,32 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var FaxQueue = sequelize.define('FaxQueue', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    description: {
-      type: DataTypes.STRING,
-    },
-    timeout: {
-      type: DataTypes.INTEGER,
-    },
-    strategy: {
-      type: DataTypes.ENUM('rrmemory', 'beepall')
-    }
-  }, {
-    tableName: 'fax_queues',
-    associate: function(models) {
-      // hasMany relations
-      FaxQueue.belongsToMany(models.User, {
-        hooks: true,
-        through: models.UserHasFaxQueue
-      });
-    }
-  });
-
-  return FaxQueue;
-
-};
\ No newline at end of file
diff --git a/server/models/fax_room.js b/server/models/fax_room.js
index 112966e..44353de 100644
--- a/server/models/fax_room.js
+++ b/server/models/fax_room.js
@@ -1,25 +1 @@
-/**
- * Fax Room Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var FaxRoom = sequelize.define('FaxRoom', {
-    roomId: DataTypes.STRING,
-    // subject: DataTypes.STRING,
-    from: DataTypes.STRING,
-    status: DataTypes.ENUM('NEW', 'OPEN', 'PENDING', 'SOLVED', 'CLOSED')
-  }, {
-    tableName: 'fax_rooms',
-    associate: function(models) {
-      // hasMany relations
-      FaxRoom.hasMany(models.FaxMessage);
-      FaxRoom.belongsTo(models.FaxAccount);
-      FaxRoom.belongsTo(models.User);
-    }
-  });
-
-  return FaxRoom;
-};
\ No newline at end of file
diff --git a/server/models/freshdesk_account.js b/server/models/freshdesk_account.js
index 09ca148..2ee6557 100644
--- a/server/models/freshdesk_account.js
+++ b/server/models/freshdesk_account.js
@@ -1,24 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('FreshdeskAccount', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING,
-    username: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    remoteUri: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    apiKey: DataTypes.STRING
-  }, {
-    tableName: 'freshdesk_accounts',
-    associate: function(models) {
-      models.FreshdeskAccount.hasMany(models.FreshdeskConfiguration, {
-        foreignKey: 'AccountId'
-      });
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/freshdesk_configuration.js b/server/models/freshdesk_configuration.js
index 4a1299a..af2e4cd 100644
--- a/server/models/freshdesk_configuration.js
+++ b/server/models/freshdesk_configuration.js
@@ -1,27 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('FreshdeskConfiguration', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING
-  }, {
-    tableName: 'freshdesk_configurations',
-    associate: function(models) {
-      models.FreshdeskConfiguration.belongsTo(models.FreshdeskAccount, {
-        foreignKey: 'AccountId'
-      });
-      models.FreshdeskConfiguration.hasMany(models.FreshdeskField, {
-        as: 'Subject',
-        foreignKey: 'SubjectId'
-      });
-      models.FreshdeskConfiguration.hasMany(models.FreshdeskField, {
-        as: 'Description',
-        foreignKey: 'DescriptionId'
-      });
-      models.FreshdeskConfiguration.hasMany(models.FreshdeskField, {
-        as: 'Field',
-        foreignKey: 'FieldId'
-      });
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/freshdesk_field.js b/server/models/freshdesk_field.js
index a1c54c9..c7bd722 100644
--- a/server/models/freshdesk_field.js
+++ b/server/models/freshdesk_field.js
@@ -1,26 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('FreshdeskField', {
-    type: {
-      type: DataTypes.ENUM('string', 'variable', 'key_value'),
-      defaultValue: 'string'
-    },
-    content: DataTypes.STRING,
-    key: DataTypes.STRING,
-    keyType: {
-      type: DataTypes.ENUM('string', 'variable')
-    },
-    keyContent: DataTypes.STRING,
-    idField: DataTypes.STRING,
-    customField: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: true
-    }
-  }, {
-    tableName: 'freshdesk_fields',
-    associate: function(models) {
-      models.FreshdeskField.belongsTo(models.Variable);
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/history/report_agent_history.js b/server/models/history/report_agent_history.js
index b648f4b..614e1b3 100644
--- a/server/models/history/report_agent_history.js
+++ b/server/models/history/report_agent_history.js
@@ -1,67 +1 @@
-/**
- * Agent Log Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-  var ReportAgentHistory = sequelize.define('ReportAgentHistory', {
-    uniqueid: DataTypes.STRING,
-    calleridnum: DataTypes.STRING,
-    calleridname: DataTypes.STRING,
-    queue: DataTypes.STRING,
-    interface: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    agentcalledAt: DataTypes.DATE,
-    agentconnectAt: DataTypes.DATE,
-    holdtime: DataTypes.INTEGER,
-    agentcomplete: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentcompleteAt: DataTypes.DATE,
-    talktime: DataTypes.INTEGER,
-    agentacw: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    acwtime: DataTypes.INTEGER,
-    reason: DataTypes.STRING,
-    agentringnoanswer: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentringnoanswerAt: DataTypes.DATE,
-    agentdump: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentdumpAt: DataTypes.DATE,
-    channel: DataTypes.STRING,
-    channelstate: DataTypes.INTEGER,
-    channelstatedesc: DataTypes.STRING,
-    connectedlinenum: DataTypes.STRING,
-    connectedlinename: DataTypes.STRING,
-    language: DataTypes.STRING,
-    accountcode: DataTypes.STRING,
-    context: DataTypes.STRING,
-    exten: DataTypes.STRING,
-    priority: DataTypes.STRING,
-    destchannel: DataTypes.STRING,
-    destchannelstate: DataTypes.INTEGER,
-    destchannelstatedesc: DataTypes.STRING,
-    destcalleridnum: DataTypes.STRING,
-    destcalleridname: DataTypes.STRING,
-    destconnectedlinenum: DataTypes.STRING,
-    destconnectedlinename: DataTypes.STRING,
-    destlanguage: DataTypes.STRING,
-    destaccountcode: DataTypes.STRING,
-    destcontext: DataTypes.STRING,
-    destexten: DataTypes.STRING,
-    destpriority: DataTypes.STRING,
-    destuniqueid: DataTypes.STRING
-  }, {
-    tableName: 'report_agent_history'
-  });
-
-  ReportAgentHistory.removeAttribute('id');
-  return ReportAgentHistory;
-};
\ No newline at end of file
diff --git a/server/models/history/report_call_history.js b/server/models/history/report_call_history.js
index ec7ea22..25cbb5f 100644
--- a/server/models/history/report_call_history.js
+++ b/server/models/history/report_call_history.js
@@ -1,56 +1 @@
-/**
- * CDR Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportCallHistory = sequelize.define('ReportCallHistory', {
-    accountcode: DataTypes.STRING,
-    source: DataTypes.STRING,
-    destination: DataTypes.STRING,
-    destinationcontext: DataTypes.STRING,
-    callerid: DataTypes.STRING,
-    channel: DataTypes.STRING,
-    destinationchannel: DataTypes.STRING,
-    lastapplication: DataTypes.STRING,
-    lastdata: DataTypes.STRING,
-    starttime: DataTypes.DATE,
-    answertime: {
-      type: DataTypes.DATE,
-      set: function(answertime) {
-        if (answertime !== '') {
-          this.setDataValue('answertime', answertime);
-        } else {
-          this.setDataValue('answertime', null);
-        }
-      }
-    },
-    endtime: DataTypes.DATE,
-    duration: DataTypes.INTEGER,
-    billableseconds: DataTypes.INTEGER,
-    disposition: DataTypes.STRING,
-    amaflags: DataTypes.STRING,
-    uniqueid: {
-      type: DataTypes.STRING,
-      primaryKey: true
-    },
-    userfield: DataTypes.STRING,
-  }, {
-    tableName: 'report_call_history',
-    associate: function(models) {
-      ReportCallHistory.hasMany(models.ReportQueueHistory, {
-        as: 'HistoryQueueCalls',
-        foreignKey: 'uniqueid',
-        constraints: false
-      });
-      ReportCallHistory.hasMany(models.ReportAgentHistory, {
-        as: 'HistoryReportAgents',
-        foreignKey: 'uniqueid',
-        constraints: false
-      });
-    }
-  });
-
-  ReportCallHistory.removeAttribute('id');
-  return ReportCallHistory;
-};
\ No newline at end of file
diff --git a/server/models/history/report_dial_history.js b/server/models/history/report_dial_history.js
index 634bdfe..258bb90 100644
--- a/server/models/history/report_dial_history.js
+++ b/server/models/history/report_dial_history.js
@@ -1,42 +1 @@
-/**
- * DIAL Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportDialHistory = sequelize.define('ReportDialHistory', {
-    channel: DataTypes.STRING,
-    channelstate: DataTypes.INTEGER,
-    channelstatedesc: DataTypes.STRING,
-    calleridnum: DataTypes.STRING,
-    calleridname: DataTypes.STRING,
-    connectedlinenum: DataTypes.STRING,
-    connectedlinename: DataTypes.STRING,
-    language: DataTypes.STRING,
-    accountcode: DataTypes.STRING,
-    context: DataTypes.STRING,
-    exten: DataTypes.STRING,
-    priority: DataTypes.INTEGER,
-    uniqueid: DataTypes.STRING,
-    destchannel: DataTypes.STRING,
-    destchannelstate: DataTypes.INTEGER,
-    destchannelstatedesc: DataTypes.STRING,
-    destcalleridnum: DataTypes.STRING,
-    destcalleridname: DataTypes.STRING,
-    destconnectedlinenum: DataTypes.STRING,
-    destconnectedlinename: DataTypes.STRING,
-    destlanguage: DataTypes.STRING,
-    destaccountcode: DataTypes.STRING,
-    destcontext: DataTypes.STRING,
-    destexten: DataTypes.STRING,
-    destpriority: DataTypes.INTEGER,
-    destuniqueid: DataTypes.STRING,
-    dialstring: DataTypes.STRING,
-    dialstatus: DataTypes.STRING
-  }, {
-    tableName: 'report_dial_history'
-  });
-
-  ReportDialHistory.removeAttribute('id');
-  return ReportDialHistory;
-};
\ No newline at end of file
diff --git a/server/models/history/report_integration_history.js b/server/models/history/report_integration_history.js
index 9b80979..7cdd585 100644
--- a/server/models/history/report_integration_history.js
+++ b/server/models/history/report_integration_history.js
@@ -1,84 +1 @@
-/**
- * report_integrations Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportIntegrationHistory = sequelize.define('ReportIntegrationHistory', {
-    integration: DataTypes.STRING,
-    event: DataTypes.STRING,
-    contacts: DataTypes.STRING,
-    uniqueid: DataTypes.STRING,
-    calleridnum: DataTypes.STRING,
-    calleridname: DataTypes.STRING,
-    queue: DataTypes.STRING,
-    interface: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    agentcalledAt: DataTypes.DATE,
-    agentconnectAt: DataTypes.DATE,
-    holdtime: DataTypes.INTEGER,
-    agentcomplete: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentcompleteAt: DataTypes.DATE,
-    talktime: DataTypes.INTEGER,
-    agentacw: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    acwtime: DataTypes.INTEGER,
-    reason: DataTypes.STRING,
-    agentringnoanswer: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentringnoanswerAt: DataTypes.DATE,
-    agentdump: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentdumpAt: DataTypes.DATE,
-    lastevent: DataTypes.STRING,
-    channel: DataTypes.STRING,
-    channelstate: DataTypes.INTEGER,
-    channelstatedesc: DataTypes.STRING,
-    connectedlinenum: DataTypes.STRING,
-    connectedlinename: DataTypes.STRING,
-    language: DataTypes.STRING,
-    accountcode: DataTypes.STRING,
-    context: DataTypes.STRING,
-    exten: DataTypes.STRING,
-    priority: DataTypes.STRING,
-    destchannel: DataTypes.STRING,
-    destchannelstate: DataTypes.INTEGER,
-    destchannelstatedesc: DataTypes.STRING,
-    destcalleridnum: DataTypes.STRING,
-    destcalleridname: DataTypes.STRING,
-    destconnectedlinenum: DataTypes.STRING,
-    destconnectedlinename: DataTypes.STRING,
-    destlanguage: DataTypes.STRING,
-    destaccountcode: DataTypes.STRING,
-    destcontext: DataTypes.STRING,
-    destexten: DataTypes.STRING,
-    destpriority: DataTypes.STRING,
-    destuniqueid: DataTypes.STRING,
-    messageId: DataTypes.STRING,
-    inReplyTo: DataTypes.STRING,
-    subject: DataTypes.STRING,
-    from: DataTypes.STRING,
-    to: DataTypes.STRING,
-    cc: DataTypes.STRING,
-    attachment: DataTypes.TEXT,
-    html: DataTypes.TEXT,
-    text: DataTypes.TEXT,
-    status: {
-      type: DataTypes.ENUM('SENT', 'SENDING', 'RECEIVED', 'FAILED')
-    }
-  }, {
-    tableName: 'report_integration_history'
-  });
-
-  ReportIntegrationHistory.removeAttribute('id');
-  return ReportIntegrationHistory;
-};
\ No newline at end of file
diff --git a/server/models/history/report_mail_session_history.js b/server/models/history/report_mail_session_history.js
index f64724e..913609a 100644
--- a/server/models/history/report_mail_session_history.js
+++ b/server/models/history/report_mail_session_history.js
@@ -1,31 +1 @@
-/**
- * Agent Log Model
- */
-
-var moment = require('moment');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportMailSessionHistory = sequelize.define('ReportMailSessionHistory', {
-    uniqueid: {
-      type: DataTypes.INTEGER
-    },
-    subject: DataTypes.STRING,
-    from: DataTypes.STRING,
-    cc: DataTypes.STRING,
-    attachment: DataTypes.BOOLEAN,
-    accountname: DataTypes.STRING,
-    accountaddress: DataTypes.STRING,
-    fullname: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    mailqueuename: DataTypes.STRING,
-    mailjoinAt: DataTypes.DATE,
-    mailleaveAt: DataTypes.DATE,
-    mailunmanagedAt: DataTypes.DATE,
-  }, {
-    tableName: 'report_mail_session_history'
-  });
-
-  ReportMailSessionHistory.removeAttribute('id');
-  return ReportMailSessionHistory;
-};
\ No newline at end of file
diff --git a/server/models/history/report_member_history.js b/server/models/history/report_member_history.js
index dbb928a..7c6bea7 100644
--- a/server/models/history/report_member_history.js
+++ b/server/models/history/report_member_history.js
@@ -1,23 +1 @@
-/**
- * DIAL Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportMemberHistory = sequelize.define('ReportMemberHistory', {
-    stateinterface: DataTypes.STRING,
-    queue: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    interface: DataTypes.STRING,
-    state: DataTypes.INTEGER,
-    statedesc: DataTypes.STRING,
-    enterdate: DataTypes.DATE,
-    exitdate: DataTypes.DATE,
-    reason: DataTypes.STRING
-  }, {
-    tableName: 'report_member_history'
-  });
-
-  ReportMemberHistory.removeAttribute('id');
-  return ReportMemberHistory;
-};
\ No newline at end of file
diff --git a/server/models/history/report_queue_history.js b/server/models/history/report_queue_history.js
index 2f4a450..107011c 100644
--- a/server/models/history/report_queue_history.js
+++ b/server/models/history/report_queue_history.js
@@ -1,39 +1 @@
-/**
- * QueueLog Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportQueueHistory = sequelize.define('ReportQueueHistory', {
-    uniqueid: DataTypes.STRING,
-    calleridnum: DataTypes.STRING,
-    calleridname: DataTypes.STRING,
-    queue: DataTypes.STRING,
-    queuecallerjoinAt: DataTypes.DATE,
-    queuecallerleaveAt: DataTypes.DATE,
-    position: DataTypes.INTEGER,
-    count: DataTypes.INTEGER,
-    queuecallerabandon: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    },
-    queuecallerabandonAt: DataTypes.DATE,
-    queuecallercompleteAt: DataTypes.DATE,
-    originalposition: DataTypes.INTEGER,
-    channel: DataTypes.STRING,
-    channelstate: DataTypes.INTEGER,
-    channelstatedesc: DataTypes.STRING,
-    connectedlinenum: DataTypes.STRING,
-    connectedlinename: DataTypes.STRING,
-    language: DataTypes.STRING,
-    accountcode: DataTypes.STRING,
-    context: DataTypes.STRING,
-    exten: DataTypes.STRING,
-    priority: DataTypes.STRING,
-  }, {
-    tableName: 'report_queue_history'
-  });
-
-  ReportQueueHistory.removeAttribute('id');
-  return ReportQueueHistory;
-};
\ No newline at end of file
diff --git a/server/models/index.js b/server/models/index.js
index d299094..b379fe0 100644
--- a/server/models/index.js
+++ b/server/models/index.js
@@ -1,96 +1 @@
-"use strict";
-
-var fs = require("fs");
-var path = require("path");
-var config = require('../config/environment');
-var Sequelize = require("sequelize");
-var moment = require('moment');
-
-//Used to disable all warnings for Promise!
-Sequelize.Promise.config({
-  // Enables all warnings except forgotten return statements.
-  warnings: {
-    wForgottenReturn: false
-  }
-});
-
-var sequelize = new Sequelize(config.db.database, config.db.username, config.db.password, {
-  host: config.db.host,
-  dialect: 'mysql',
-  timezone: moment().format("Z"),
-  logging: false
-});
-
-var db = {};
-
-fs
-  .readdirSync(__dirname)
-  .filter(function (file) {
-    return (fs.lstatSync(path.join(__dirname, file)).isFile()) &&
-      (file.indexOf(".") !== 0) && (file.indexOf('.spec.') === -1) && (file !== "index.js");
-  })
-  .forEach(function (file) {
-    var model = sequelize["import"](path.join(__dirname, file));
-    db[model.name] = model;
-  });
-
-// Invoke associations on each of the models
-Object.keys(db).forEach(function (modelName) {
-  if (db[modelName].options.hasOwnProperty('associate')) {
-    db[modelName].options.associate(db);
-  }
-});
-
-db.history = {};
-
-var sequelize_history = new Sequelize(config.db_history.database, config.db_history.username, config.db_history.password, {
-  host: config.db_history.host,
-  dialect: 'mysql',
-  timezone: moment().format("Z"),
-  logging: false
-});
-
-fs
-  .readdirSync(path.join(__dirname, 'history'))
-  .filter(function (file) {
-    return (fs.lstatSync(path.join(__dirname, 'history', file)).isFile()) &&
-      (file.indexOf(".") !== 0) && (file.indexOf('.spec.') === -1) && (file !== "index.js");
-  })
-  .forEach(function (file) {
-    var model = sequelize_history["import"](path.join(__dirname, 'history', file));
-    db.history[model.name] = model;
-  });
-
-// Invoke associations on each of the models
-Object.keys(db.history).forEach(function (modelName) {
-  if (db.history[modelName].options.hasOwnProperty('associate')) {
-    db.history[modelName].options.associate(db.history);
-  }
-});
-
-db.ContactPhone.hasMany(db.history.ReportCallHistory, {
-  as: 'HistoryInbounds',
-  foreignKey: 'source',
-  constraints: false
-});
-db.ContactPhone.hasMany(db.history.ReportCallHistory, {
-  as: 'HistoryOutbounds',
-  foreignKey: 'destination',
-  constraints: false
-});
-db.ContactEmail.hasMany(db.history.ReportMailSessionHistory, {
-  as: 'HistoryInboundMessages',
-  foreignKey: 'from',
-  constraints: false
-});
-db.ContactEmail.hasMany(db.history.ReportMailSessionHistory, {
-  as: 'HistoryOutboundMessages',
-  foreignKey: 'to',
-  constraints: false
-});
-
-db.sequelize = sequelize;
-db.sequelize_history = sequelize_history;
-db.Sequelize = Sequelize;
-
-module.exports = db;
\ No newline at end of file
diff --git a/server/models/integration.js b/server/models/integration.js
index 53aecce..6c523fa 100644
--- a/server/models/integration.js
+++ b/server/models/integration.js
@@ -1,62 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Integration = sequelize.define('Integration', {
-    name: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: 'unique_name_and_version',
-      validate: {
-        notEmpty: true
-      }
-    },
-    version: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: 'unique_name_and_version',
-      validate: {
-        notEmpty: true
-      }
-    },
-    main: {
-      type: DataTypes.STRING,
-      defaultValue: 'app.js'
-    },
-    filename: {
-      type: DataTypes.STRING,
-      // allowNull: false,
-      // validate: {
-      //   notEmpty: true
-      // }
-    },
-    path: {
-      type: DataTypes.STRING,
-      // allowNull: false,
-      // validate: {
-      //   notEmpty: true
-      // }
-    },
-    type: {
-      type: DataTypes.STRING,
-      // allowNull: false
-    },
-    size: {
-      type: DataTypes.INTEGER,
-      // allowNull: false
-    },
-    active: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    },
-    author: DataTypes.STRING,
-    logo: DataTypes.STRING,
-    state: DataTypes.STRING,
-    description: DataTypes.STRING
-  }, {
-    tableName: 'integrations'
-  });
-
-  return Integration;
-
-};
\ No newline at end of file
diff --git a/server/models/interval.js b/server/models/interval.js
index ea0e3de..58cf422 100644
--- a/server/models/interval.js
+++ b/server/models/interval.js
@@ -1,661 +1 @@
-/* jshint indent: 2 */
-var util = require('util');
-var _ = require('lodash');
-
-var Applications = {
-  Dial: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Set',
-    appdata: 'CALLERID(all)=%s'
-  }, {
-    app: 'Dial',
-    appdata: '%s,%s,%s,%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Dial Application End'
-  }],
-  Queue: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Answer',
-    appdata: ''
-  }, {
-    app: 'Queue',
-    appdata: '%s,%s,%s,%s,%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Queue Application End'
-  }],
-  Playback: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Playback',
-    appdata: '%s,%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Playback Application End'
-  }],
-  AGI: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'AGI',
-    appdata: 'agi://127.0.0.1/square,%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'AGI Application End'
-  }],
-  Goto: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Goto',
-    appdata: '%s,%s,%d',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Goto Application End'
-  }],
-  Hangup: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Hangup',
-    appdata: '%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Hangup Application End'
-  }],
-  Set: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Set',
-    appdata: '%s=%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Set Application End'
-  }],
-  custom: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'custom',
-    appdata: '%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Custom Application End'
-  }],
-  Voicemail: [{
-    app: 'GotoIfTime',
-    appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-  }, {
-    app: 'Voicemail',
-    appdata: '%s',
-    isApp: true
-  }, {
-    app: 'NoOp',
-    appdata: 'Voicemail Application End'
-  }]
-};
-
-
-module.exports = function(sequelize, DataTypes) {
-  var Interval = sequelize.define('Interval', {
-    name: {
-      type: DataTypes.STRING,
-      unique: 'name_intervalid'
-    },
-    interval: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    IntervalId: {
-      type: DataTypes.INTEGER(11),
-      unique: 'name_intervalid'
-    }
-  }, {
-    tableName: 'intervals',
-    associate: function(models) {
-      Interval.hasMany(models.Interval, {
-        as: 'SubIntervals',
-        onDelete: 'cascade'
-      });
-      Interval.hasMany(models.VoiceExtension, {
-        as: 'VoiceExtensions'
-      });
-      Interval.hasMany(models.MailApplication, {
-        as: 'MailApplications'
-      });
-      Interval.hasMany(models.MailApplication, {
-        as: 'ChatApplications'
-      });
-
-      Interval.afterUpdate(function(interval) {
-        if (interval.IntervalId !== null) {
-          interval.getVoiceExtensions()
-            .then(function(voiceExtensions) {
-              var appdata;
-              var oldappdata;
-              voiceExtensions.forEach(function(element) {
-                oldappdata = element.appdata.split('?');
-                element.appdata = util.format('%s?%s', interval.interval, oldappdata[1]);
-                element.interval = interval.interval;
-                element.save()
-                  .catch(function(err) {
-                    console.log(err);
-                  });
-              })
-            })
-            .catch(function(err) {
-              console.log(err);
-            });
-        }
-      })
-
-      Interval.beforeDestroy(function(interval) {
-        console.log('interval not yet deleted');
-        if (interval.IntervalId !== null) {
-          appRewrite(interval, models);
-        }
-      })
-
-      Interval.afterCreate(function(interval) {
-        console.log('interval created');
-        if (interval.IntervalId !== null) {
-          appRewrite(interval, models, true);
-        }
-      })
-    }
-  });
-
-  function appRewrite(hookInterval, models, create) {
-    console.log('Finding extension apps..');
-    models.VoiceExtension
-      .findAll({
-        where: {
-          IntervalId: hookInterval.IntervalId,
-        }
-      })
-      .then(function(tmpVoiceExtensions) {
-        if (tmpVoiceExtensions && tmpVoiceExtensions.length > 0) {
-          console.log('Extensions found');
-          var voiceExtensionsIds = _.uniq(_.pluck(_.pluck(tmpVoiceExtensions, 'dataValues'), 'VoiceExtensionId'), true);
-          models.VoiceExtension
-            .findAll({
-              where: {
-                VoiceExtensionId: voiceExtensionsIds,
-                isApp: true
-              }
-            })
-            .then(function(voiceExtensions) {
-              console.log('Starting transaction before destroy..');
-              return sequelize.transaction(function(t) {
-                  console.log('Destroying extension rows...');
-                  return models.VoiceExtension.destroy({
-                      where: {
-                        VoiceExtensionId: voiceExtensionsIds
-                      }
-                    }, {
-                      transaction: t
-                    })
-                    .then(function() {
-                      console.log('Destroyed extensions');
-                      voiceExtensions = _.pluck(voiceExtensions, 'dataValues');
-                      var intervalIds = _.filter(_.pluck(voiceExtensions, 'IntervalId'), function(elem) {
-                        return elem !== null;
-                      });
-                      console.log('Finding intervals');
-                      Interval
-                        .findAll({
-                          where: {
-                            IntervalId: intervalIds,
-                            id: {
-                              $ne: create ? null : hookInterval.id
-                            }
-                          }
-                        })
-                        .then(function(intervals) {
-
-                          console.log('Found intervals, creating extension rows...');
-                          var extByExtId;
-                          voiceExtensionsIds.forEach(function(extId) {
-                            extByExtId = _.filter(voiceExtensions, function(elem) {
-                              return elem.VoiceExtensionId == extId;
-                            });
-                            var priority = 2;
-                            var interval;
-                            extByExtId.forEach(function(tmpElem) {
-                              console.log('Creating app..');
-                              var application = _.cloneDeep(Applications[tmpElem.app]);
-                              if (!application || tmpElem.customApp) {
-                                application = [{
-                                  app: 'GotoIfTime',
-                                  appdata: '%s?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                                }, {
-                                  app: 'custom',
-                                  appdata: '%s',
-                                  isApp: true
-                                }, {
-                                  app: 'NoOp',
-                                  appdata: 'Custom Application End'
-                                }];
-                              }
-                              console.log('PRIORITY');
-                              console.log(priority);
-                              var appGroup = util.format('%s%s%s', tmpElem.context, tmpElem.exten, priority);
-                              tmpElem.interval = tmpElem.interval || '*,*,*,*';
-                              var tmpIntervals = _.filter(intervals, function(elem) {
-                                return (elem.IntervalId == tmpElem.IntervalId);
-                              });
-                              if (tmpIntervals && tmpIntervals.length > 0) {
-                                application.splice(0, 1);
-                                tmpIntervals.forEach(function(elem, index) {
-                                  // interval = createInterval(elem);
-                                  application.unshift({
-                                    app: 'GotoIfTimeFromArray',
-                                    appdata: elem.interval + '?%s,${EXTEN},%s:%s,${EXTEN},%s',
-                                    IntervalId: elem.id,
-                                    isInterval: true,
-                                    interval: elem.interval
-                                  });
-                                })
-                              }
-                              priority = appCreate(application, tmpElem, appGroup, tmpIntervals || [], priority);
-                              console.log('returned priority');
-                              console.log(priority);
-                              models.VoiceExtension
-                                .bulkCreate(application)
-                            });
-                          });
-
-                          console.log('THE END');
-                        })
-                    })
-                })
-                .catch(function(err) {
-                  console.log(err);
-                });
-            })
-            .catch(function(err) {
-              console.log(err);
-            });
-        }
-      })
-      .catch(function(err) {
-        console.log(err);
-      });
-  }
-
-
-  return Interval;
-};
-
-// function createInterval(element) {
-//   var interval = [];
-//   if (element.t_from && element.t_from !== '') {
-//     interval[0] = element.t_from;
-//     if (element.t_to && element.t_to !== '') {
-//       interval[0] += '-' + element.t_to;
-//     }
-//   } else {
-//     interval[0] = '*';
-//   }
-//
-//   if (element.wd_from && element.wd_from !== '') {
-//     interval[1] = element.wd_from;
-//     if (element.wd_to && element.wd_to !== '') {
-//       interval[1] += '-' + element.wd_to;
-//     }
-//   } else {
-//     interval[1] = '*';
-//   }
-//
-//   if (element.md_from && element.md_from !== '') {
-//     interval[2] = element.md_from;
-//     if (element.md_to && element.md_to !== '') {
-//       interval[2] += '-' + element.md_to;
-//     }
-//   } else {
-//     interval[2] = '*';
-//   }
-//
-//   if (element.m_from && element.m_from !== '') {
-//     interval[3] = element.m_from;
-//     if (element.m_to && element.m_to !== '') {
-//       interval[3] += '-' + element.m_to;
-//     }
-//   } else {
-//     interval[3] = '*';
-//   }
-//
-//   return interval.join(',');
-// }
-
-function appCreate(application, element, appGroup, intervals, priority) {
-  var intLength = intervals.length;
-  if (element.customApp) {
-    element.app = 'custom';
-  }
-  switch (element.app) {
-    case 'Dial':
-      if (!element.callerID) {
-        _.remove(application, {
-          app: 'Set'
-        });
-      }
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'Dial':
-            if (element.type === 'outbound') {
-              elem.interval = element.interval;
-              elem.trunk = element.trunk;
-              elem.TrunkId = element.TrunkId;
-              elem.cutdigits = element.cutdigits || 0;
-              elem.callerID = element.callerID || null;
-              // elem.appdata = util.format('SIP/${EXTEN:%d}@%s', elem.cutdigits, elem.trunk);
-            } else {
-              elem.IntervalId = element.IntervalId;
-              elem.interval = element.interval;
-              elem.interface = element.interface;
-              elem.app_options = element.app_options || '';
-              elem.timeout = element.timeout || '';
-              elem.url = element.url || '';
-              elem.appdata = util.format(elem.appdata, element.interface, elem.timeout, elem.app_options ? elem.app_options.replace(',', '') : '', elem.url);
-            }
-            break;
-          case 'Set':
-            elem.appdata = util.format(elem.appdata, element.callerID);
-            break;
-          case 'NoOp':
-            if (element.type === 'outbound') {
-              elem.appdata = 'Outbound Dial Application End';
-            }
-            break;
-          default:
-
-        }
-      });
-      break;
-    case 'Queue':
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'Queue':
-            elem.IntervalId = element.IntervalId;
-            elem.app_options = element.app_options || '';
-            elem.audiofile = element.audiofile || '';
-            elem.queue = element.queue;
-            elem.interval = element.interval;
-            elem.interface = element.interface;
-            elem.app_options = element.app_options;
-            elem.timeout = element.timeout || '';
-            elem.url = element.url || '';
-            elem.appdata = util.format(elem.appdata, elem.queue, elem.app_options ? elem.app_options.replace(',', '') : '', elem.url, elem.audiofile, elem.timeout);
-            break;
-          default:
-
-        }
-      });
-      break;
-    case 'Playback':
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'Playback':
-            elem.IntervalId = element.IntervalId;
-            elem.interval = element.interval;
-            elem.audiofile = element.audiofile || '';
-            elem.app_options = element.app_options || '';
-            elem.appdata = util.format(elem.appdata, elem.audiofile, elem.app_options ? elem.app_options.replace(',', '') : '');
-            break;
-          default:
-
-        }
-      });
-      break;
-    case 'AGI':
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'AGI':
-            elem.IntervalId = element.IntervalId;
-            elem.interval = element.interval;
-            elem.project = element.project;
-            elem.appdata = util.format(elem.appdata, elem.project);
-            break;
-          default:
-
-        }
-      });
-      break;
-    case 'Goto':
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'Goto':
-            elem.IntervalId = element.IntervalId;
-            elem.interval = element.interval;
-            elem.alt_priority = element.alt_priority;
-            elem.alt_extension = element.alt_extension;
-            elem.alt_context = element.alt_context;
-            elem.appdata = util.format(elem.appdata, elem.alt_context, elem.alt_extension, elem.alt_priority);
-            break;
-          default:
-
-        }
-      });
-      break;
-    case 'Hangup':
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'Hangup':
-            elem.IntervalId = element.IntervalId;
-            elem.interval = element.interval;
-            elem.causecode = element.causecode;
-            elem.appdata = util.format(elem.appdata, elem.causecode);
-            break;
-          default:
-
-        }
-      });
-      break;
-    case 'Set':
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'Set':
-            elem.IntervalId = element.IntervalId;
-            elem.interval = element.interval;
-            elem.variable = element.variable;
-            elem.value = element.value;
-            elem.appdata = util.format(elem.appdata, elem.variable, elem.value);
-            break;
-          default:
-
-        }
-      });
-      break;
-    case 'custom':
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'custom':
-            elem.IntervalId = element.IntervalId;
-            elem.interval = element.interval;
-            elem.app = elem.customApp = element.customApp;
-            elem.appdata = util.format(elem.appdata, element.appdata);
-            break;
-          default:
-
-        }
-      });
-      break;
-    case 'Voicemail':
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'Voicemail':
-            elem.IntervalId = element.IntervalId;
-            elem.interval = element.interval;
-            elem.mailbox = element.mailbox;
-            elem.appdata = util.format(elem.appdata, elem.mailbox);
-            break;
-          default:
-
-        }
-      });
-      break;
-    default:
-      application.forEach(function(elem, index) {
-        elem.exten = element.exten;
-        elem.type = element.type;
-        elem.context = element.context;
-        elem.VoiceExtensionId = element.VoiceExtensionId;
-        elem.priority = priority ? priority++ : element.priority++;
-        elem.appGroup = appGroup;
-        switch (elem.app) {
-          case 'GotoIfTime':
-            elem.appdata = util.format(elem.appdata, element.IntervalId ? '*,*,*,*' : element.interval, elem.context, elem.priority + 1, elem.context, (elem.priority + 2));
-            break;
-          case 'GotoIfTimeFromArray':
-            elem.app = 'GotoIfTime';
-            elem.appdata = util.format(elem.appdata, elem.context, elem.priority + intLength - index, elem.context, (index + 1) < intLength ? (elem.priority + 1) : (elem.priority + 2));
-            break;
-          case 'custom':
-            elem.IntervalId = element.IntervalId;
-            elem.interval = element.interval;
-            elem.app = elem.customApp = element.customApp;
-            elem.appdata = util.format(elem.appdata, element.appdata);
-            break;
-          default:
-
-        }
-      });
-
-  }
-  if (priority) {
-    return priority;
-  }
-}
\ No newline at end of file
diff --git a/server/models/mail_account.js b/server/models/mail_account.js
index caf5343..ef600dd 100644
--- a/server/models/mail_account.js
+++ b/server/models/mail_account.js
@@ -1,32 +1 @@
-/**
- * Chat Website Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-	var MailAccount = sequelize.define('MailAccount', {
-		description: DataTypes.STRING,
-		name: {
-			type: DataTypes.STRING,
-			unique: true
-		},
-		address: DataTypes.STRING,
-	}, {
-		tableName: 'mail_accounts',
-		associate: function(models) {
-			MailAccount.hasMany(models.MailRoom);
-			MailAccount.hasMany(models.MailTemplate);
-			MailAccount.hasMany(models.MailApplication);
-			MailAccount.hasOne(models.MailServerIn, {
-				onDelete: 'cascade',
-				hooks: true
-			});
-			MailAccount.hasOne(models.MailServerOut, {
-				onDelete: 'cascade',
-				hooks: true
-			});
-		}
-	});
-
-	return MailAccount;
-};
\ No newline at end of file
diff --git a/server/models/mail_application.js b/server/models/mail_application.js
index 9b0c53a..5ee3ac7 100644
--- a/server/models/mail_application.js
+++ b/server/models/mail_application.js
@@ -1,30 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var MailApplication = sequelize.define('MailApplication', {
-    app: {
-      type: DataTypes.ENUM('queue', 'agent')
-    },
-    priority: {
-      type: DataTypes.INTEGER
-    },
-    timeout: {
-      type: DataTypes.INTEGER
-    },
-    interval: {
-      type: DataTypes.STRING
-    }
-  }, {
-    tableName: 'mail_applications',
-    associate: function(models) {
-      // hasMany relations
-      MailApplication.belongsTo(models.MailAccount);
-      MailApplication.belongsTo(models.Interval);
-      MailApplication.belongsTo(models.MailQueue);
-      MailApplication.belongsTo(models.User);
-    }
-  });
-
-  return MailApplication;
-};
\ No newline at end of file
diff --git a/server/models/mail_attachment.js b/server/models/mail_attachment.js
index c201c4c..1562a11 100644
--- a/server/models/mail_attachment.js
+++ b/server/models/mail_attachment.js
@@ -1,24 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var MailAttachment = sequelize.define('MailAttachment', {
-		contentDisposition: DataTypes.STRING,
-		fileName: DataTypes.STRING,
-		path: DataTypes.STRING,
-		contentType: DataTypes.STRING,
-		transferEncoding: DataTypes.STRING,
-		generatedFileName: DataTypes.STRING,
-		contentId: DataTypes.STRING,
-		checksum: DataTypes.STRING,
-		length: DataTypes.INTEGER,
-	}, {
-		tableName: 'mail_attachments'
-	});
-
-	return MailAttachment;
-};
\ No newline at end of file
diff --git a/server/models/mail_automation.js b/server/models/mail_automation.js
index 218cb9c..5a09901 100644
--- a/server/models/mail_automation.js
+++ b/server/models/mail_automation.js
@@ -1,23 +1 @@
-/**
- * User Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var MailAutomation = sequelize.define('MailAutomation', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING,
-    conditions: DataTypes.TEXT,
-    actions: DataTypes.TEXT,
-    status: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    }
-  }, {
-    tableName: 'mail_automations'
-  });
-
-  return MailAutomation;
-};
\ No newline at end of file
diff --git a/server/models/mail_business_automation.js b/server/models/mail_business_automation.js
index bc4c03d..87fd398 100644
--- a/server/models/mail_business_automation.js
+++ b/server/models/mail_business_automation.js
@@ -1,32 +1 @@
-/**
- * User Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var MailBusinessAutomation = sequelize.define('MailBusinessAutomation', {
-    name: {
-      type: DataTypes.STRING
-    },
-    description: {
-      type: DataTypes.STRING
-    },
-    status: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    },
-    jobId: {
-      type: DataTypes.INTEGER
-    }
-  }, {
-    tableName: 'mail_business_automations',
-    associate: function(models) {
-      MailBusinessAutomation.hasMany(models.BusinessAction);
-      MailBusinessAutomation.hasMany(models.BusinessCondition);
-    }
-  });
-
-  return MailBusinessAutomation;
-};
\ No newline at end of file
diff --git a/server/models/mail_message.js b/server/models/mail_message.js
index a2e3670..f1eee6e 100644
--- a/server/models/mail_message.js
+++ b/server/models/mail_message.js
@@ -1,56 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function (sequelize, DataTypes) {
-
-	var MailMessage = sequelize.define('MailMessage', {
-		messageId: DataTypes.STRING,
-		inReplyTo: DataTypes.STRING,
-		subject: DataTypes.STRING,
-		from: DataTypes.STRING,
-		to: DataTypes.STRING,
-		cc: DataTypes.STRING,
-		bcc: DataTypes.STRING,
-		attachment: DataTypes.TEXT,
-		html: DataTypes.TEXT,
-		text: DataTypes.TEXT,
-		reason: DataTypes.TEXT,
-		status: {
-			type: DataTypes.ENUM('SENT', 'SENDING', 'RECEIVED', 'FAILED')
-		}
-	}, {
-		tableName: 'mail_messages',
-		associate: function (models) {
-			MailMessage.belongsTo(models.MailRoom);
-
-			MailMessage.belongsTo(models.ContactEmail, {
-				as: 'From'
-			});
-
-			MailMessage.belongsToMany(models.ContactEmail, {
-				as: 'To',
-				through: 'mail_message_has_to',
-				onDelete: 'cascade'
-			});
-
-			MailMessage.belongsToMany(models.ContactEmail, {
-				as: 'Cc',
-				through: 'mail_message_has_cc',
-				onDelete: 'cascade'
-			});
-
-			MailMessage.belongsToMany(models.ContactEmail, {
-				as: 'Bcc',
-				through: 'mail_message_has_bcc',
-				onDelete: 'cascade'
-			});
-
-			MailMessage.hasMany(models.MailAttachment);
-		}
-	});
-
-	return MailMessage;
-};
\ No newline at end of file
diff --git a/server/models/mail_queue.js b/server/models/mail_queue.js
index 16905f1..e666a60 100644
--- a/server/models/mail_queue.js
+++ b/server/models/mail_queue.js
@@ -1,30 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var MailQueue = sequelize.define('MailQueue', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    description: {
-      type: DataTypes.STRING,
-    },
-    timeout: {
-      type: DataTypes.INTEGER,
-    },
-    strategy: {
-      type: DataTypes.ENUM('rrmemory', 'beepall')
-    }
-  }, {
-    tableName: 'mail_queues',
-    associate: function(models) {
-      // hasMany relations
-      MailQueue.belongsToMany(models.User, {
-        through: models.UserHasMailQueue
-      });
-    }
-  });
-
-  return MailQueue;
-};
\ No newline at end of file
diff --git a/server/models/mail_room.js b/server/models/mail_room.js
index ea4e337..452331c 100644
--- a/server/models/mail_room.js
+++ b/server/models/mail_room.js
@@ -1,31 +1 @@
-/**
- * Chat Website Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-	var MailRoom = sequelize.define('MailRoom', {
-		subject: DataTypes.STRING,
-		from: DataTypes.STRING,
-		attachment: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		status: {
-			type: DataTypes.ENUM('NEW', 'OPEN', 'CLOSED'),
-			defaultValue: 'NEW'
-		}
-	}, {
-		tableName: 'mail_rooms',
-		associate: function(models) {
-			MailRoom.hasMany(models.MailMessage);
-			MailRoom.hasMany(models.MailRoomStatus, {
-				as: 'States'
-			});
-			MailRoom.belongsTo(models.MailAccount);
-			MailRoom.belongsTo(models.User);
-		}
-	});
-
-	return MailRoom;
-};
\ No newline at end of file
diff --git a/server/models/mail_room_status.js b/server/models/mail_room_status.js
index 20b29e9..f5a29c4 100644
--- a/server/models/mail_room_status.js
+++ b/server/models/mail_room_status.js
@@ -1,14 +1 @@
-/**
- * Chat Website Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-	var MailRoomStatus = sequelize.define('MailRoomStatus', {
-		status: DataTypes.ENUM('RECEIVED', 'ASSIGNED', 'REPLIED', 'ARCHIVED')
-	}, {
-		tableName: 'mail_room_states'
-	});
-
-	return MailRoomStatus;
-};
\ No newline at end of file
diff --git a/server/models/mail_server_in.js b/server/models/mail_server_in.js
index 9f92813..1becf79 100644
--- a/server/models/mail_server_in.js
+++ b/server/models/mail_server_in.js
@@ -1,41 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var MailServerIn = sequelize.define('MailServerIn', {
-		description: DataTypes.STRING,
-		host: DataTypes.STRING,
-		username: DataTypes.STRING,
-		password: DataTypes.STRING,
-		port: DataTypes.INTEGER,
-		mailbox: DataTypes.STRING,
-		ssl: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		delete: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		filter: {
-			type: DataTypes.ENUM('UNSEEN'),
-			defaultValue: 'UNSEEN'
-		},
-		protocol: {
-			type: DataTypes.ENUM('IMAP', 'POP3'),
-			defaultValue: 'IMAP'
-		},
-		state: {
-			type: DataTypes.ENUM('CONNECTED', 'DISCONNECTED', 'ERROR', 'UNKNOWN'),
-			defaultValue: 'UNKNOWN'
-		}
-	}, {
-		tableName: 'mail_servers_in'
-	});
-
-	return MailServerIn;
-};
\ No newline at end of file
diff --git a/server/models/mail_server_out.js b/server/models/mail_server_out.js
index 9a89310..79022cb 100644
--- a/server/models/mail_server_out.js
+++ b/server/models/mail_server_out.js
@@ -1,34 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-var smtpTransport = require('nodemailer-smtp-transport');
-var nodemailer = require('nodemailer');
-
-module.exports = function (sequelize, DataTypes) {
-
-	var MailServerOut = sequelize.define('MailServerOut', {
-		description: DataTypes.STRING,
-		host: DataTypes.STRING,
-		username: DataTypes.STRING,
-		password: DataTypes.STRING,
-		port: DataTypes.INTEGER,
-		ssl: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		service: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		state: {
-			type: DataTypes.ENUM('CONNECTED', 'DISCONNECTED', 'ERROR', 'UNKNOWN'),
-			defaultValue: 'UNKNOWN'
-		},
-	}, {
-		tableName: 'mail_servers_out'
-	});
-
-	return MailServerOut;
-};
\ No newline at end of file
diff --git a/server/models/mail_template.js b/server/models/mail_template.js
index 4ab80a8..438c17a 100644
--- a/server/models/mail_template.js
+++ b/server/models/mail_template.js
@@ -1,24 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var MailTemplate = sequelize.define('MailTemplate', {
-		name: DataTypes.STRING,
-		description: DataTypes.STRING,
-		subject: DataTypes.STRING,
-		from: DataTypes.STRING,
-		to: DataTypes.STRING,
-		cc: DataTypes.STRING,
-		attachment: DataTypes.TEXT,
-		html: DataTypes.TEXT,
-		text: DataTypes.TEXT
-	}, {
-		tableName: 'mail_templates'
-	});
-
-	return MailTemplate;
-};
\ No newline at end of file
diff --git a/server/models/mail_trigger.js b/server/models/mail_trigger.js
index 73be985..da41f9b 100644
--- a/server/models/mail_trigger.js
+++ b/server/models/mail_trigger.js
@@ -1,23 +1 @@
-/**
- * User Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var MailTrigger = sequelize.define('MailTrigger', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING,
-    conditions: DataTypes.TEXT,
-    actions: DataTypes.TEXT,
-    status: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    }
-  }, {
-    tableName: 'mail_triggers'
-  });
-
-  return MailTrigger;
-};
\ No newline at end of file
diff --git a/server/models/metric.js b/server/models/metric.js
index 6341030..03eb3b6 100644
--- a/server/models/metric.js
+++ b/server/models/metric.js
@@ -1,21 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Metric = sequelize.define('Metric', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true,
-      validate: {
-        notEmpty: true
-      },
-    },
-    metric: DataTypes.TEXT,
-    description: DataTypes.STRING
-  }, {
-    tableName: 'metrics'
-  });
-
-  return Metric;
-
-};
\ No newline at end of file
diff --git a/server/models/module.js b/server/models/module.js
index c2bef6c..c32df9c 100644
--- a/server/models/module.js
+++ b/server/models/module.js
@@ -1,27 +1 @@
-/**
- * Module Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Module = sequelize.define('Module', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true,
-      allowNull: false,
-      validate: {
-        notEmpty: true
-      }
-    },
-    title: DataTypes.STRING
-  }, {
-    tableName: 'modules',
-    associate: function(models) {
-      Module.belongsToMany(models.User, {
-        through: 'user_has_modules'
-      });
-    }
-  });
-
-  return Module;
-};
\ No newline at end of file
diff --git a/server/models/motionbar.js b/server/models/motionbar.js
index ad6cba8..73fd03e 100644
--- a/server/models/motionbar.js
+++ b/server/models/motionbar.js
@@ -1,32 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Motionbar = sequelize.define('Motionbar', {
-    action: {
-      type: DataTypes.ENUM,
-      values: ['hangup'],
-      allowNull: false
-    },
-    state: {
-      type: DataTypes.ENUM,
-      values: ['incoming', 'active'],
-    },
-    phone: {
-      type: DataTypes.STRING
-    }
-  }, {
-    tableName: 'motionbar',
-    associate: function(models) {
-      Motionbar.belongsTo(models.User, {
-        as: 'Admin'
-      });
-      Motionbar.belongsTo(models.User, {
-        as: 'User'
-      });
-    }
-  });
-
-  return Motionbar;
-
-};
\ No newline at end of file
diff --git a/server/models/report_agent.js b/server/models/report_agent.js
index 726ce95..17023fa 100644
--- a/server/models/report_agent.js
+++ b/server/models/report_agent.js
@@ -1,71 +1 @@
-/**
- * Agent Log Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportAgent = sequelize.define('ReportAgent', {
-    uniqueid: DataTypes.STRING,
-    calleridnum: DataTypes.STRING,
-    calleridname: DataTypes.STRING,
-    queue: DataTypes.STRING,
-    interface: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    agentcalledAt: DataTypes.DATE,
-    agentconnectAt: DataTypes.DATE,
-    holdtime: DataTypes.INTEGER,
-    agentcomplete: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentcompleteAt: DataTypes.DATE,
-    talktime: DataTypes.INTEGER,
-    agentacw: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    acwtime: DataTypes.INTEGER,
-    reason: DataTypes.STRING,
-    agentringnoanswer: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentringnoanswerAt: DataTypes.DATE,
-    agentdump: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentdumpAt: DataTypes.DATE,
-    lastevent: DataTypes.STRING,
-    channel: DataTypes.STRING,
-    channelstate: DataTypes.INTEGER,
-    channelstatedesc: DataTypes.STRING,
-    connectedlinenum: DataTypes.STRING,
-    connectedlinename: DataTypes.STRING,
-    language: DataTypes.STRING,
-    accountcode: DataTypes.STRING,
-    context: DataTypes.STRING,
-    exten: DataTypes.STRING,
-    priority: DataTypes.STRING,
-    destchannel: DataTypes.STRING,
-    destchannelstate: DataTypes.INTEGER,
-    destchannelstatedesc: DataTypes.STRING,
-    destcalleridnum: DataTypes.STRING,
-    destcalleridname: DataTypes.STRING,
-    destconnectedlinenum: DataTypes.STRING,
-    destconnectedlinename: DataTypes.STRING,
-    destlanguage: DataTypes.STRING,
-    destaccountcode: DataTypes.STRING,
-    destcontext: DataTypes.STRING,
-    destexten: DataTypes.STRING,
-    destpriority: DataTypes.STRING,
-    destuniqueid: DataTypes.STRING
-  }, {
-    tableName: 'report_agent',
-    indexes: [{
-      fields: ['uniqueid', 'destuniqueid']
-    }]
-  });
-
-  return ReportAgent;
-};
\ No newline at end of file
diff --git a/server/models/report_call.js b/server/models/report_call.js
index c73d367..0e43086 100644
--- a/server/models/report_call.js
+++ b/server/models/report_call.js
@@ -1,55 +1 @@
-/**
- * CDR Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportCall = sequelize.define('ReportCall', {
-    accountcode: DataTypes.STRING,
-    source: DataTypes.STRING,
-    destination: DataTypes.STRING,
-    destinationcontext: DataTypes.STRING,
-    callerid: DataTypes.STRING,
-    channel: DataTypes.STRING,
-    destinationchannel: DataTypes.STRING,
-    lastapplication: DataTypes.STRING,
-    lastdata: DataTypes.STRING,
-    starttime: DataTypes.DATE,
-    answertime: {
-      type: DataTypes.DATE,
-      set: function(answertime) {
-        if (answertime !== '') {
-          this.setDataValue('answertime', answertime);
-        } else {
-          this.setDataValue('answertime', null);
-        }
-      }
-    },
-    endtime: DataTypes.DATE,
-    duration: DataTypes.INTEGER,
-    billableseconds: DataTypes.INTEGER,
-    disposition: DataTypes.STRING,
-    amaflags: DataTypes.STRING,
-    uniqueid: {
-      type: DataTypes.STRING,
-      primaryKey: true
-    },
-    userfield: DataTypes.STRING,
-  }, {
-    tableName: 'report_call',
-    associate: function(models) {
-      ReportCall.hasMany(models.ReportQueue, {
-        as: 'QueueCalls',
-        foreignKey: 'uniqueid',
-        constraints: false
-      })
-      ReportCall.hasMany(models.ReportAgent, {
-        as: 'ReportAgents',
-        foreignKey: 'uniqueid',
-        constraints: false
-      })
-    }
-  });
-
-  return ReportCall;
-};
\ No newline at end of file
diff --git a/server/models/report_chat.js b/server/models/report_chat.js
index 08a9e88..b71a116 100644
--- a/server/models/report_chat.js
+++ b/server/models/report_chat.js
@@ -1,48 +1 @@
-/**
- * Agent Log Model
- */
-
-var moment = require('moment');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportChat = sequelize.define('ReportChat', {
-    uniqueid: DataTypes.INTEGER,
-    sorting: DataTypes.INTEGER,
-    timeslot: DataTypes.INTEGER,
-    visitorname: DataTypes.STRING,
-    visitoremail: DataTypes.STRING,
-    websitename: DataTypes.STRING,
-    websiteaddress: DataTypes.STRING,
-    websiteid: DataTypes.INTEGER,
-    application: DataTypes.STRING,
-    fullname: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    agentid: DataTypes.INTEGER,
-    chatqueuename: DataTypes.STRING,
-    lastevent: DataTypes.STRING,
-    agentcalledAt: DataTypes.DATE,
-    chatroomid: DataTypes.INTEGER,
-    connectId: {
-      type: DataTypes.INTEGER,
-      unique: true
-    },
-    agentconnectedAt: DataTypes.DATE,
-    connect: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-      set: function(agentconnectedAt) {
-        this.setDataValue('connectId', this.uniqueid);
-        this.setDataValue('agentconnectedAt', moment().format("YYYY-MM-DD HH:mm:ss"));
-        this.setDataValue('reason', 'agent');
-        this.setDataValue('lastevent', 'agent');
-      }
-    },
-    agentringnoanswerAt: DataTypes.DATE,
-    reason: DataTypes.STRING
-  }, {
-    tableName: 'report_chat'
-  });
-
-  return ReportChat;
-};
\ No newline at end of file
diff --git a/server/models/report_chat_session.js b/server/models/report_chat_session.js
index a895225..ebc9ae6 100644
--- a/server/models/report_chat_session.js
+++ b/server/models/report_chat_session.js
@@ -1,32 +1 @@
-/**
- * Agent Log Model
- */
-
-var moment = require('moment');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportChatSession = sequelize.define('ReportChatSession', {
-    uniqueid: {
-      type: DataTypes.INTEGER,
-      unique: true
-    },
-    visitorname: DataTypes.STRING,
-    visitoremail: DataTypes.STRING,
-    websitename: DataTypes.STRING,
-    websiteaddress: DataTypes.STRING,
-    websiteid: DataTypes.INTEGER,
-    fullname: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    agentid: DataTypes.INTEGER,
-    chatqueuename: DataTypes.STRING,
-    chatroomid: DataTypes.INTEGER,
-    chatjoinAt: DataTypes.DATE,
-    chatleaveAt: DataTypes.DATE,
-    chatunmanagedAt: DataTypes.DATE,
-  }, {
-    tableName: 'report_chat_session'
-  });
-
-  return ReportChatSession;
-};
\ No newline at end of file
diff --git a/server/models/report_dial.js b/server/models/report_dial.js
index 273f50d..13c2939 100644
--- a/server/models/report_dial.js
+++ b/server/models/report_dial.js
@@ -1,44 +1 @@
-/**
- * DIAL Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportDial = sequelize.define('ReportDial', {
-    channel: DataTypes.STRING,
-    channelstate: DataTypes.INTEGER,
-    channelstatedesc: DataTypes.STRING,
-    calleridnum: DataTypes.STRING,
-    calleridname: DataTypes.STRING,
-    connectedlinenum: DataTypes.STRING,
-    connectedlinename: DataTypes.STRING,
-    language: DataTypes.STRING,
-    accountcode: DataTypes.STRING,
-    context: DataTypes.STRING,
-    exten: DataTypes.STRING,
-    priority: DataTypes.INTEGER,
-    uniqueid: DataTypes.STRING,
-    destchannel: DataTypes.STRING,
-    destchannelstate: DataTypes.INTEGER,
-    destchannelstatedesc: DataTypes.STRING,
-    destcalleridnum: DataTypes.STRING,
-    destcalleridname: DataTypes.STRING,
-    destconnectedlinenum: DataTypes.STRING,
-    destconnectedlinename: DataTypes.STRING,
-    destlanguage: DataTypes.STRING,
-    destaccountcode: DataTypes.STRING,
-    destcontext: DataTypes.STRING,
-    destexten: DataTypes.STRING,
-    destpriority: DataTypes.INTEGER,
-    destuniqueid: DataTypes.STRING,
-    dialstring: DataTypes.STRING,
-    dialstatus: DataTypes.STRING
-  }, {
-    tableName: 'report_dial',
-    indexes: [{
-      fields: ['uniqueid']
-    }]
-  });
-
-  return ReportDial;
-};
\ No newline at end of file
diff --git a/server/models/report_integration.js b/server/models/report_integration.js
index 2a3347e..20775a3 100644
--- a/server/models/report_integration.js
+++ b/server/models/report_integration.js
@@ -1,83 +1 @@
-/**
- * report_integrations Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportIntegration = sequelize.define('ReportIntegration', {
-    integration: DataTypes.STRING,
-    event: DataTypes.STRING,
-    contacts: DataTypes.STRING,
-    uniqueid: DataTypes.STRING,
-    calleridnum: DataTypes.STRING,
-    calleridname: DataTypes.STRING,
-    queue: DataTypes.STRING,
-    interface: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    agentcalledAt: DataTypes.DATE,
-    agentconnectAt: DataTypes.DATE,
-    holdtime: DataTypes.INTEGER,
-    agentcomplete: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentcompleteAt: DataTypes.DATE,
-    talktime: DataTypes.INTEGER,
-    agentacw: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    acwtime: DataTypes.INTEGER,
-    reason: DataTypes.STRING,
-    agentringnoanswer: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentringnoanswerAt: DataTypes.DATE,
-    agentdump: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-    },
-    agentdumpAt: DataTypes.DATE,
-    lastevent: DataTypes.STRING,
-    channel: DataTypes.STRING,
-    channelstate: DataTypes.INTEGER,
-    channelstatedesc: DataTypes.STRING,
-    connectedlinenum: DataTypes.STRING,
-    connectedlinename: DataTypes.STRING,
-    language: DataTypes.STRING,
-    accountcode: DataTypes.STRING,
-    context: DataTypes.STRING,
-    exten: DataTypes.STRING,
-    priority: DataTypes.STRING,
-    destchannel: DataTypes.STRING,
-    destchannelstate: DataTypes.INTEGER,
-    destchannelstatedesc: DataTypes.STRING,
-    destcalleridnum: DataTypes.STRING,
-    destcalleridname: DataTypes.STRING,
-    destconnectedlinenum: DataTypes.STRING,
-    destconnectedlinename: DataTypes.STRING,
-    destlanguage: DataTypes.STRING,
-    destaccountcode: DataTypes.STRING,
-    destcontext: DataTypes.STRING,
-    destexten: DataTypes.STRING,
-    destpriority: DataTypes.STRING,
-    destuniqueid: DataTypes.STRING,
-    messageId: DataTypes.STRING,
-    inReplyTo: DataTypes.STRING,
-    subject: DataTypes.STRING,
-    from: DataTypes.STRING,
-    to: DataTypes.STRING,
-    cc: DataTypes.STRING,
-    attachment: DataTypes.TEXT,
-    html: DataTypes.TEXT,
-    text: DataTypes.TEXT,
-    status: {
-      type: DataTypes.ENUM('SENT', 'SENDING', 'RECEIVED', 'FAILED')
-    }
-  }, {
-    tableName: 'report_integration'
-  });
-
-  return ReportIntegration;
-};
\ No newline at end of file
diff --git a/server/models/report_mail.js b/server/models/report_mail.js
index 8fd17ff..e70eccc 100644
--- a/server/models/report_mail.js
+++ b/server/models/report_mail.js
@@ -1,49 +1 @@
-/**
- * Agent Log Model
- */
-
-var moment = require('moment');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportMail = sequelize.define('ReportMail', {
-    uniqueid: DataTypes.INTEGER,
-    sorting: DataTypes.INTEGER,
-    timeslot: DataTypes.INTEGER,
-    subject: DataTypes.STRING,
-    from: DataTypes.STRING,
-    cc: DataTypes.STRING,
-    attachment: DataTypes.BOOLEAN,
-    accountname: DataTypes.STRING,
-    accountaddress: DataTypes.STRING,
-    application: DataTypes.STRING,
-    fullname: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    agentid: DataTypes.INTEGER,
-    mailqueuename: DataTypes.STRING,
-    mailroomid: DataTypes.INTEGER,
-    lastevent: DataTypes.STRING,
-    agentcalledAt: DataTypes.DATE,
-    connectId: {
-      type: DataTypes.INTEGER,
-      unique: true
-    },
-    agentconnectedAt: DataTypes.DATE,
-    connect: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false,
-      set: function(agentconnectedAt) {
-        this.setDataValue('connectId', this.uniqueid);
-        this.setDataValue('agentconnectedAt', moment().format("YYYY-MM-DD HH:mm:ss"));
-        this.setDataValue('reason', 'agent');
-        this.setDataValue('lastevent', 'agent');
-      }
-    },
-    agentringnoanswerAt: DataTypes.DATE,
-    reason: DataTypes.STRING
-  }, {
-    tableName: 'report_mail'
-  });
-
-  return ReportMail;
-};
\ No newline at end of file
diff --git a/server/models/report_mail_session.js b/server/models/report_mail_session.js
index b2ce44f..d6a5732 100644
--- a/server/models/report_mail_session.js
+++ b/server/models/report_mail_session.js
@@ -1,30 +1 @@
-/**
- * Agent Log Model
- */
-
-var moment = require('moment');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportMailSession = sequelize.define('ReportMailSession', {
-    uniqueid: {
-      type: DataTypes.INTEGER
-    },
-    subject: DataTypes.STRING,
-    from: DataTypes.STRING,
-    cc: DataTypes.STRING,
-    attachment: DataTypes.BOOLEAN,
-    accountname: DataTypes.STRING,
-    accountaddress: DataTypes.STRING,
-    fullname: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    mailqueuename: DataTypes.STRING,
-    mailjoinAt: DataTypes.DATE,
-    mailleaveAt: DataTypes.DATE,
-    mailunmanagedAt: DataTypes.DATE,
-  }, {
-    tableName: 'report_mail_session'
-  });
-
-  return ReportMailSession;
-};
\ No newline at end of file
diff --git a/server/models/report_member.js b/server/models/report_member.js
index 293bace..d4b949d 100644
--- a/server/models/report_member.js
+++ b/server/models/report_member.js
@@ -1,25 +1 @@
-/**
- * DIAL Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportMember = sequelize.define('ReportMember', {
-    stateinterface: DataTypes.STRING,
-    queue: DataTypes.STRING,
-    membername: DataTypes.STRING,
-    interface: DataTypes.STRING,
-    state: DataTypes.INTEGER,
-    statedesc: DataTypes.STRING,
-    enterdate: DataTypes.DATE,
-    exitdate: DataTypes.DATE,
-    reason: DataTypes.STRING
-  }, {
-    tableName: 'report_member',
-    indexes: [{
-      fields: ['queue', 'membername', 'state', 'enterdate', 'exitdate']
-    }]
-  });
-
-  return ReportMember;
-};
\ No newline at end of file
diff --git a/server/models/report_queue.js b/server/models/report_queue.js
index fb70f88..517bd86 100644
--- a/server/models/report_queue.js
+++ b/server/models/report_queue.js
@@ -1,41 +1 @@
-/**
- * QueueLog Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportQueue = sequelize.define('ReportQueue', {
-    uniqueid: DataTypes.STRING,
-    calleridnum: DataTypes.STRING,
-    calleridname: DataTypes.STRING,
-    queue: DataTypes.STRING,
-    queuecallerjoinAt: DataTypes.DATE,
-    queuecallerleaveAt: DataTypes.DATE,
-    position: DataTypes.INTEGER,
-    count: DataTypes.INTEGER,
-    queuecallerabandon: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    },
-    queuecallerabandonAt: DataTypes.DATE,
-    queuecallercompleteAt: DataTypes.DATE,
-    originalposition: DataTypes.INTEGER,
-    channel: DataTypes.STRING,
-    channelstate: DataTypes.INTEGER,
-    channelstatedesc: DataTypes.STRING,
-    connectedlinenum: DataTypes.STRING,
-    connectedlinename: DataTypes.STRING,
-    language: DataTypes.STRING,
-    accountcode: DataTypes.STRING,
-    context: DataTypes.STRING,
-    exten: DataTypes.STRING,
-    priority: DataTypes.STRING,
-  }, {
-    tableName: 'report_queue',
-    indexes: [{
-      fields: ['uniqueid']
-    }]
-  });
-
-  return ReportQueue;
-};
\ No newline at end of file
diff --git a/server/models/report_square.js b/server/models/report_square.js
index 62a8e0c..b509638 100644
--- a/server/models/report_square.js
+++ b/server/models/report_square.js
@@ -1,89 +1 @@
-/**
- * Context Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportSquare = sequelize.define('ReportSquare', {
-    network: {
-      type: DataTypes.STRING,
-    },
-    network_script: {
-      type: DataTypes.STRING,
-    },
-    request: {
-      type: DataTypes.STRING,
-    },
-    channel: {
-      type: DataTypes.STRING,
-    },
-    language: {
-      type: DataTypes.STRING,
-    },
-    type: {
-      type: DataTypes.STRING,
-    },
-    uniqueid: {
-      type: DataTypes.STRING,
-    },
-    version: {
-      type: DataTypes.STRING,
-    },
-    callerid: {
-      type: DataTypes.STRING,
-    },
-    calleridname: {
-      type: DataTypes.STRING,
-    },
-    callingpres: {
-      type: DataTypes.STRING,
-    },
-    callingani2: {
-      type: DataTypes.STRING,
-    },
-    callington: {
-      type: DataTypes.STRING,
-    },
-    callingtns: {
-      type: DataTypes.STRING,
-    },
-    dnid: {
-      type: DataTypes.STRING,
-    },
-    rdnis: {
-      type: DataTypes.STRING,
-    },
-    context: {
-      type: DataTypes.STRING,
-    },
-    extension: {
-      type: DataTypes.STRING,
-    },
-    priority: {
-      type: DataTypes.STRING,
-    },
-    enhanced: {
-      type: DataTypes.STRING,
-    },
-    accountcode: {
-      type: DataTypes.STRING,
-    },
-    threadid: {
-      type: DataTypes.STRING,
-    },
-    project_name: {
-      type: DataTypes.STRING,
-    },
-    joinAt: {
-      type: DataTypes.DATE,
-    },
-    leaveAt: {
-      type: DataTypes.DATE,
-      unique: true
-    }
-  }, {
-    tableName: 'report_square'
-  });
-
-  return ReportSquare;
-};
\ No newline at end of file
diff --git a/server/models/report_square_detail.js b/server/models/report_square_detail.js
index b9a2f4c..139e93d 100644
--- a/server/models/report_square_detail.js
+++ b/server/models/report_square_detail.js
@@ -1,25 +1 @@
-/**
- * Context Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportSquareDetail = sequelize.define('ReportSquareDetail', {
-    uniqueid: {
-      type: DataTypes.STRING,
-    },
-    node: {
-      type: DataTypes.STRING,
-    },
-    application: {
-      type: DataTypes.STRING,
-    },
-    data: {
-      type: DataTypes.STRING,
-    }
-  }, {
-    tableName: 'report_square_details'
-  });
-
-  return ReportSquareDetail;
-};
\ No newline at end of file
diff --git a/server/models/report_tree.js b/server/models/report_tree.js
index 2c14bfe..f9bd738 100644
--- a/server/models/report_tree.js
+++ b/server/models/report_tree.js
@@ -1,12 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ReportTree = sequelize.define('ReportTree', {
-    tree: DataTypes.TEXT
-  }, {
-    tableName: 'report_trees'
-  });
-
-  return ReportTree;
-};
+var _0x4a2c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x54\x72\x65\x65","\x54\x45\x58\x54","\x72\x65\x70\x6F\x72\x74\x5F\x74\x72\x65\x65\x73","\x64\x65\x66\x69\x6E\x65"];_0x4a2c[0];module[_0x4a2c[1]]=function(_0xe975x1,_0xe975x2){var _0xe975x3=_0xe975x1[_0x4a2c[5]](_0x4a2c[2],{tree:_0xe975x2[_0x4a2c[3]]},{tableName:_0x4a2c[4]});return _0xe975x3;};
\ No newline at end of file
diff --git a/server/models/salesforce_account.js b/server/models/salesforce_account.js
index c7319f2..3e1e7c0 100644
--- a/server/models/salesforce_account.js
+++ b/server/models/salesforce_account.js
@@ -1,24 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('SalesforceAccount', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING,
-    username: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    remoteUri: DataTypes.STRING,
-    password: DataTypes.STRING,
-    clientId: DataTypes.STRING,
-    clientSecret: DataTypes.STRING,
-    securityToken: DataTypes.STRING
-  }, {
-    tableName: 'salesforce_accounts',
-    associate: function(models) {
-      models.SalesforceAccount.hasMany(models.SalesforceConfiguration, {
-        foreignKey: 'AccountId'
-      });
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/salesforce_configuration.js b/server/models/salesforce_configuration.js
index 6850116..5c735e1 100644
--- a/server/models/salesforce_configuration.js
+++ b/server/models/salesforce_configuration.js
@@ -1,27 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('SalesforceConfiguration', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING
-  }, {
-    tableName: 'salesforce_configurations',
-    associate: function(models) {
-      models.SalesforceConfiguration.belongsTo(models.SalesforceAccount, {
-        foreignKey: 'AccountId'
-      });
-      models.SalesforceConfiguration.hasMany(models.SalesforceField, {
-        as: 'Subject',
-        foreignKey: 'SubjectId'
-      });
-      models.SalesforceConfiguration.hasMany(models.SalesforceField, {
-        as: 'Description',
-        foreignKey: 'DescriptionId'
-      });
-      models.SalesforceConfiguration.hasMany(models.SalesforceField, {
-        as: 'Field',
-        foreignKey: 'FieldId'
-      });
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/salesforce_field.js b/server/models/salesforce_field.js
index f3a3501..f66b8f8 100644
--- a/server/models/salesforce_field.js
+++ b/server/models/salesforce_field.js
@@ -1,22 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('SalesforceField', {
-    type: {
-      type: DataTypes.ENUM('string', 'variable', 'key_value'),
-      defaultValue: 'string'
-    },
-    content: DataTypes.STRING,
-    key: DataTypes.STRING,
-    keyType: {
-      type: DataTypes.ENUM('string', 'variable')
-    },
-    keyContent: DataTypes.STRING,
-    idField: DataTypes.STRING
-  }, {
-    tableName: 'salesforce_fields',
-    associate: function(models) {
-      models.SalesforceField.belongsTo(models.Variable);
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/settings.js b/server/models/settings.js
index 3599ea7..66a139c 100644
--- a/server/models/settings.js
+++ b/server/models/settings.js
@@ -1,52 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Settings = sequelize.define('Settings', {
-    license: DataTypes.TEXT,
-    mac: {
-      type: DataTypes.STRING(17),
-      allowNull: false,
-      validate: {
-        notEmpty: true,
-        // isMac: function(value) {
-        //   if (!getmac.isMac(value)) {
-        //     throw new Error('Invalid Mac!');
-        //   }
-        // }
-      }
-    },
-    netmask: {
-      type: DataTypes.STRING(15),
-      allowNull: false,
-      validate: {
-        notEmpty: true,
-        isIP: true
-      }
-    },
-    address: {
-      type: DataTypes.STRING(15),
-      allowNull: false,
-      validate: {
-        notEmpty: true,
-        isIP: true
-      }
-    },
-    min_internal: {
-      type: DataTypes.INTEGER(11),
-      unique: true
-    },
-    agi_port: {
-      type: DataTypes.INTEGER(11)
-    },
-    automation_timeout: {
-      type: DataTypes.INTEGER(11),
-      defaultValue: 3600
-    }
-  }, {
-    tableName: 'settings'
-  });
-
-  return Settings;
-
-};
\ No newline at end of file
diff --git a/server/models/square_odbc.js b/server/models/square_odbc.js
index 0e632c6..b7f6a13 100644
--- a/server/models/square_odbc.js
+++ b/server/models/square_odbc.js
@@ -1,23 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var SquareOdbc = sequelize.define('SquareOdbc', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true,
-      validate: {
-        notEmpty: true
-      },
-    },
-    dsn: {
-      type: DataTypes.STRING,
-    },
-    description: DataTypes.STRING
-  }, {
-    tableName: 'square_odbc'
-  });
-
-  return SquareOdbc;
-
-};
\ No newline at end of file
diff --git a/server/models/square_project.js b/server/models/square_project.js
index 9e68d35..211d0c5 100644
--- a/server/models/square_project.js
+++ b/server/models/square_project.js
@@ -1,28 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var SquareProject = sequelize.define('SquareProject', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true,
-      validate: {
-        notEmpty: true
-      }
-    },
-    description: DataTypes.STRING,
-    preproduction: {
-      type: DataTypes.TEXT,
-      length: 'long'
-    },
-    production: {
-      type: DataTypes.TEXT,
-      length: 'long'
-    }
-  }, {
-    tableName: 'square_projects',
-  });
-
-  return SquareProject;
-
-};
\ No newline at end of file
diff --git a/server/models/sugarcrm_account.js b/server/models/sugarcrm_account.js
index 318d984..e1d2b74 100644
--- a/server/models/sugarcrm_account.js
+++ b/server/models/sugarcrm_account.js
@@ -1,20 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('SugarcrmAccount', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING,
-    username: {
-      type: DataTypes.STRING
-    },
-    remoteUri: DataTypes.STRING,
-    password: DataTypes.STRING
-  }, {
-    tableName: 'sugarcrm_accounts',
-    associate: function(models) {
-      models.SugarcrmAccount.hasMany(models.SugarcrmConfiguration, {
-        foreignKey: 'AccountId'
-      });
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/sugarcrm_configuration.js b/server/models/sugarcrm_configuration.js
index cae512a..d66f076 100644
--- a/server/models/sugarcrm_configuration.js
+++ b/server/models/sugarcrm_configuration.js
@@ -1,27 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('SugarcrmConfiguration', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING
-  }, {
-    tableName: 'sugarcrm_configurations',
-    associate: function(models) {
-      models.SugarcrmConfiguration.belongsTo(models.SugarcrmAccount, {
-        foreignKey: 'AccountId'
-      });
-      models.SugarcrmConfiguration.hasMany(models.SugarcrmField, {
-        as: 'Subject',
-        foreignKey: 'SubjectId'
-      });
-      models.SugarcrmConfiguration.hasMany(models.SugarcrmField, {
-        as: 'Description',
-        foreignKey: 'DescriptionId'
-      });
-      models.SugarcrmConfiguration.hasMany(models.SugarcrmField, {
-        as: 'Field',
-        foreignKey: 'FieldId'
-      });
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/sugarcrm_field.js b/server/models/sugarcrm_field.js
index 7998058..46e7298 100644
--- a/server/models/sugarcrm_field.js
+++ b/server/models/sugarcrm_field.js
@@ -1,22 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-  return sequelize.define('SugarcrmField', {
-    type: {
-      type: DataTypes.ENUM('string', 'variable', 'key_value'),
-      defaultValue: 'string'
-    },
-    content: DataTypes.STRING,
-    key: DataTypes.STRING,
-    keyType: {
-      type: DataTypes.ENUM('string', 'variable')
-    },
-    keyContent: DataTypes.STRING,
-    idField: DataTypes.STRING
-  }, {
-    tableName: 'sugarcrm_fields',
-    associate: function(models) {
-      models.SugarcrmField.belongsTo(models.Variable);
-    }
-  });
-};
\ No newline at end of file
diff --git a/server/models/tag.js b/server/models/tag.js
index 0c3135a..5628ee8 100644
--- a/server/models/tag.js
+++ b/server/models/tag.js
@@ -1,22 +1 @@
-/**
- * tag Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Tag = sequelize.define('Tag', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true
-    }
-  }, {
-    tableName: 'tags',
-    // associate: function(models) {
-    //   Tag.belongsToMany(models.Contact, {
-    //     through: 'contact_tags'
-    //   });
-    // }
-  });
-
-  return Tag;
-};
+var _0x449b=["\x65\x78\x70\x6F\x72\x74\x73","\x54\x61\x67","\x53\x54\x52\x49\x4E\x47","\x74\x61\x67\x73","\x64\x65\x66\x69\x6E\x65"];module[_0x449b[0]]=function(_0x3120x1,_0x3120x2){var _0x3120x3=_0x3120x1[_0x449b[4]](_0x449b[1],{name:{type:_0x3120x2[_0x449b[2]],unique:true}},{tableName:_0x449b[3]});return _0x3120x3;};
\ No newline at end of file
diff --git a/server/models/team.js b/server/models/team.js
index 8310113..01ca4dd 100644
--- a/server/models/team.js
+++ b/server/models/team.js
@@ -1,32 +1 @@
-/**
- * User Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Team = sequelize.define('Team', {
-    name: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: true
-    },
-    description: {
-      type: DataTypes.STRING
-    },
-    defaultEntry: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: 0
-    }
-  }, {
-    tableName: 'teams',
-    associate: function(models) {
-      Team.belongsToMany(models.User, {
-        through: models.UserHasTeam
-      });
-    }
-  });
-
-  return Team;
-};
\ No newline at end of file
diff --git a/server/models/trigger.js b/server/models/trigger.js
index 10b80e7..e0fd0f5 100644
--- a/server/models/trigger.js
+++ b/server/models/trigger.js
@@ -1,24 +1 @@
-/**
- * User Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Trigger = sequelize.define('Trigger', {
-    name: DataTypes.STRING,
-    channel: DataTypes.STRING,
-    description: DataTypes.STRING,
-    conditions: DataTypes.TEXT,
-    actions: DataTypes.TEXT,
-    status: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    }
-  }, {
-    tableName: 'triggers'
-  });
-
-  return Trigger;
-};
\ No newline at end of file
diff --git a/server/models/trunk.js b/server/models/trunk.js
index 5f3bf67..c2ce756 100644
--- a/server/models/trunk.js
+++ b/server/models/trunk.js
@@ -1,341 +1 @@
-'use strict';
-
-var crypto = require('crypto');
-var md5 = require('md5');
-var _ = require('lodash');
-
-module.exports = function(sequelize, DataTypes) {
-  var Trunk = sequelize.define('Trunk', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true,
-      validate: {
-        notEmpty: true
-      },
-    },
-    port: {
-      type: DataTypes.INTEGER(5),
-      allowNull: true,
-    },
-    defaultuser: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    host: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'dynamic'
-    },
-    type: {
-      type: DataTypes.ENUM('friend', 'user', 'peer'),
-      allowNull: true,
-      defaultValue: 'friend'
-    },
-    context: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'from-sip'
-    },
-    permit: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    deny: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    secret: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    transport: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'udp'
-    },
-    dtmfmode: {
-      type: DataTypes.ENUM('rfc2833', 'info', 'shortinfo', 'inband',
-        'auto'),
-      allowNull: true,
-      defaultValue: 'rfc2833'
-    },
-    directmedia: {
-      type: DataTypes.ENUM('yes', 'no', 'nonat', 'update'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    nat: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'force_rport,comedia'
-    },
-    language: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'en'
-    },
-    disallow: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    allow: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'alaw;ulaw;gsm'
-    },
-    insecure: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'port,invite'
-    },
-    trustrpid: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    progressinband: {
-      type: DataTypes.ENUM('yes', 'no', 'never'),
-      allowNull: true,
-    },
-    promiscredir: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    useclientcode: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    accountcode: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    setvar: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    otherFields: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    callerid: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: '"" <>'
-    },
-    amaflags: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    callcounter: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    busylevel: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    allowoverlap: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    allowsubscribe: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    maxcallbitrate: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    rfc2833compensate: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    t38pt_usertpsource: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    regexten: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    fromdomain: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    fromuser: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    qualify: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    defaultip: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    rtptimeout: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    rtpholdtimeout: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    sendrpid: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    outboundproxy: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    callbackextension: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    qualifyfreq: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    constantssrc: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    contactpermit: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    contactdeny: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    usereqphone: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    textsupport: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    faxdetect: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    buggymwi: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    auth: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    fullname: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    trunkname: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    cid_number: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    callingpres: {
-      type: DataTypes.ENUM('ALLOWED_NOT_SCREENED',
-        'ALLOWED_PASSED_SCREEN', 'ALLOWED_FAILED_SCREEN', 'ALLOWED',
-        'PROHIB_NOT_SCREENED', 'PROHIB_PASSED_SCREEN',
-        'PROHIB_FAILED_SCREEN', 'PROHIB'),
-      allowNull: true,
-    },
-    mohinterpret: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    mohsuggest: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    subscribemwi: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    vmexten: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    description: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    autoframing: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    limitonpeers: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    rtpkeepalive: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    "call-limit": {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: null
-    },
-    g726nonstandard: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    ignoresdpversion: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    allowtransfer: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    dynamic: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    encryption: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    registry: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    }
-
-  }, {
-    tableName: 'trunks',
-    getterMethods: {
-      // profile: function() {
-      //   return {
-      //     name: this.name,
-      //     role: this.role
-      //   }
-      // }
-    },
-    associate: function(models) {
-      // BELOGNS TO MANY
-      Trunk.hasMany(models.VoiceExtension, {
-        foreignKey: 'TrunkId'
-      });
-
-
-    }
-  });
-
-  return Trunk;
-}
\ No newline at end of file
diff --git a/server/models/update.js b/server/models/update.js
index ba48b5d..6d682dd 100644
--- a/server/models/update.js
+++ b/server/models/update.js
@@ -1,13 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Update = sequelize.define('Update', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING
-  }, {
-    tableName: 'updates'
-  });
-
-  return Update;
-};
+var _0x6e35=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x55\x70\x64\x61\x74\x65","\x53\x54\x52\x49\x4E\x47","\x75\x70\x64\x61\x74\x65\x73","\x64\x65\x66\x69\x6E\x65"];_0x6e35[0];module[_0x6e35[1]]=function(_0xe2e8x1,_0xe2e8x2){var _0xe2e8x3=_0xe2e8x1[_0x6e35[5]](_0x6e35[2],{name:_0xe2e8x2[_0x6e35[3]],description:_0xe2e8x2[_0x6e35[3]]},{tableName:_0x6e35[4]});return _0xe2e8x3;};
\ No newline at end of file
diff --git a/server/models/upload.js b/server/models/upload.js
index 1bf2723..6edca5f 100644
--- a/server/models/upload.js
+++ b/server/models/upload.js
@@ -1,38 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-	var Upload = sequelize.define('Upload', {
-		name: DataTypes.STRING,
-		save_name: DataTypes.STRING,
-		display_name: {
-			type: DataTypes.STRING,
-			allowNull: false,
-			defaultValue: '',
-			validate: {
-				notEmpty: {
-					msg: "The name cannot be empty!"
-				} // don't allow empty strings
-			}
-		},
-		description: DataTypes.STRING,
-		original_path: DataTypes.STRING,
-		original_format: DataTypes.STRING,
-		original_duration: DataTypes.FLOAT,
-		original_sampleCount: DataTypes.BIGINT,
-		original_channelCount: DataTypes.INTEGER,
-		original_bitRate: DataTypes.BIGINT,
-		original_sampleRate: DataTypes.INTEGER,
-		converted_path: DataTypes.STRING,
-		converted_format: DataTypes.STRING,
-		converted_duration: DataTypes.FLOAT,
-		converted_sampleCount: DataTypes.BIGINT,
-		converted_channelCount: DataTypes.INTEGER,
-		converted_bitRate: DataTypes.BIGINT,
-		converted_sampleRate: DataTypes.INTEGER
-	}, {
-		tableName: 'upload'
-	});
-
-	return Upload;
-};
\ No newline at end of file
diff --git a/server/models/user.js b/server/models/user.js
index 5a6b165..189e984 100644
--- a/server/models/user.js
+++ b/server/models/user.js
@@ -1,579 +1 @@
-'use strict';
-
-var crypto = require('crypto');
-var md5 = require('md5');
-var _ = require('lodash');
-
-module.exports = function(sequelize, DataTypes) {
-  var User = sequelize.define('User', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true,
-      validate: {
-        notEmpty: true
-      },
-      set: function(name) {
-        this.setDataValue('name', name);
-        this.setDataValue('defaultuser', name);
-      }
-    },
-    email: {
-      type: DataTypes.STRING,
-      unique: true,
-      set: function(email) {
-        if (email) {
-          this.setDataValue('email', email.toLowerCase());
-        }
-
-      },
-      defaultValue: null
-    },
-    role: {
-      type: DataTypes.ENUM('admin', 'user', 'agent', 'telephone')
-    },
-    password: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      validate: {
-        notEmpty: true
-      },
-      set: function(password) {
-        this.salt = this.makeSalt();
-        this.setDataValue('password', this.encryptPassword(password));
-        this.setDataValue('md5secret', this.md5Password(this.name + ':asterisk:' + password));
-      }
-    },
-    provider: {
-      type: DataTypes.STRING,
-      defaultValue: 'local'
-    },
-    internal: {
-      type: DataTypes.INTEGER(11),
-      unique: true,
-      set: function(internal) {
-        this.setDataValue('internal', internal);
-        this.setDataValue('accountcode', internal);
-      }
-    },
-    salt: {
-      type: DataTypes.STRING
-    },
-    phone: {
-      type: DataTypes.STRING
-    },
-    mobile: {
-      type: DataTypes.STRING
-    },
-    address: {
-      type: DataTypes.STRING
-    },
-    zipcode: {
-      type: DataTypes.STRING
-    },
-    userpic: {
-      type: DataTypes.STRING
-    },
-    city: {
-      type: DataTypes.STRING
-    },
-    country: {
-      type: DataTypes.STRING
-    },
-    facebookUserId: {
-      type: DataTypes.INTEGER
-    },
-    twitterUserId: {
-      type: DataTypes.INTEGER
-    },
-    twitterKey: {
-      type: DataTypes.STRING
-    },
-    twitterSecret: {
-      type: DataTypes.STRING
-    },
-    github: {
-      type: DataTypes.STRING
-    },
-    openId: {
-      type: DataTypes.STRING
-    },
-    online: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    },
-    lastLoginAt: {
-      type: DataTypes.DATE
-    },
-    ipaddr: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    port: {
-      type: DataTypes.INTEGER(5),
-      allowNull: true,
-    },
-    regseconds: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    defaultuser: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    fullcontact: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    regserver: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    useragent: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    lastms: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    host: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'dynamic'
-    },
-    type: {
-      type: DataTypes.ENUM('friend', 'user', 'peer'),
-      allowNull: true,
-      defaultValue: 'friend'
-    },
-    context: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'from-sip'
-    },
-    permit: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    deny: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    secret: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    md5secret: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    remotesecret: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    transport: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'udp'
-    },
-    dtmfmode: {
-      type: DataTypes.ENUM('rfc2833', 'info', 'shortinfo', 'inband',
-        'auto'),
-      allowNull: true,
-      defaultValue: 'rfc2833'
-    },
-    directmedia: {
-      type: DataTypes.ENUM('yes', 'no', 'nonat', 'update'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    nat: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'force_rport,comedia'
-    },
-    callgroup: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    pickupgroup: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    language: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'en'
-    },
-    disallow: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'all'
-    },
-    allow: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'alaw;ulaw;gsm'
-    },
-    insecure: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'port,invite'
-    },
-    trustrpid: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    progressinband: {
-      type: DataTypes.ENUM('yes', 'no', 'never'),
-      allowNull: true,
-    },
-    promiscredir: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    useclientcode: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    accountcode: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    setvar: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    callerid: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: '"" <>'
-    },
-    amaflags: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    callcounter: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    busylevel: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    allowoverlap: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    allowsubscribe: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    videosupport: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    maxcallbitrate: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    rfc2833compensate: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    mailbox: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    "session-timers": {
-      type: DataTypes.ENUM('accept', 'refuse', 'originate'),
-      allowNull: true,
-    },
-    "session-expires": {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    "session-minse": {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    "session-refresher": {
-      type: DataTypes.ENUM('uac', 'uas'),
-      allowNull: true,
-    },
-    t38pt_usertpsource: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    regexten: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    fromdomain: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    fromuser: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    qualify: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    defaultip: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    rtptimeout: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    rtpholdtimeout: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    sendrpid: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    outboundproxy: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    callbackextension: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    timert1: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    timerb: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    qualifyfreq: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    constantssrc: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    contactpermit: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    contactdeny: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    usereqphone: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    textsupport: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    faxdetect: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    buggymwi: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    auth: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    fullname: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    trunkname: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    cid_number: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    callingpres: {
-      type: DataTypes.ENUM('ALLOWED_NOT_SCREENED',
-        'ALLOWED_PASSED_SCREEN', 'ALLOWED_FAILED_SCREEN', 'ALLOWED',
-        'PROHIB_NOT_SCREENED', 'PROHIB_PASSED_SCREEN',
-        'PROHIB_FAILED_SCREEN', 'PROHIB'),
-      allowNull: true,
-    },
-    mohinterpret: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    mohsuggest: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    parkinglot: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    hasvoicemail: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    subscribemwi: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    vmexten: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    description: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    autoframing: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    limitonpeers: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    rtpkeepalive: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    "call-limit": {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: null
-    },
-    g726nonstandard: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    ignoresdpversion: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    allowtransfer: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    dynamic: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    encryption: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    registry: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    }
-
-  }, {
-    tableName: 'users',
-    getterMethods: {
-      // profile: function() {
-      //   return {
-      //     name: this.name,
-      //     role: this.role
-      //   }
-      // }
-    },
-    instanceMethods: {
-      /**
-       * Authenticate - check if the passwords are the same
-       *
-       * @param {String} plainText
-       *        {function} callBack
-       * @api public
-       */
-      authenticate: function(plainText) {
-        return this.encryptPassword(plainText) === this.password;
-      },
-      /**
-       * Make salt
-       *
-       * @return {String}
-       * @api public
-       */
-      makeSalt: function() {
-        return crypto.randomBytes(16).toString('base64');
-      },
-      /**
-       * Encrypt password
-       *
-       * @param {String} password
-       * @return {String}
-       * @api public
-       */
-      encryptPassword: function(password) {
-        if (!password || !this.salt) return '';
-        var salt = new Buffer(this.salt, 'base64');
-        return crypto.pbkdf2Sync(password, salt, 10000, 64).toString(
-          'base64');
-      },
-      /**
-       * md5 password
-       *
-       * @param {String} password
-       * @return {String}
-       * @api public
-       */
-      md5Password: function(password) {
-        if (!password) return '';
-        return md5(password);
-      }
-    },
-    associate: function(models) {
-      // BELOGNS TO MANY
-      User.hasMany(models.ChatMessage);
-      User.hasMany(models.Contact);
-      User.belongsToMany(models.Module, {
-        through: 'user_has_modules'
-      });
-      User.belongsToMany(models.Channel, {
-        through: 'user_has_channels'
-      });
-      User.belongsToMany(models.Team, {
-        through: models.UserHasTeam
-      });
-      User.belongsToMany(models.ChatRoom, {
-        through: models.UserHasChatRoom
-      });
-      User.belongsToMany(models.MailQueue, {
-        through: models.UserHasMailQueue
-      });
-      User.belongsToMany(models.ChatQueue, {
-        through: models.UserHasChatQueue
-      });
-      User.belongsToMany(models.VoiceQueue, {
-        through: models.UserHasVoiceQueue
-      });
-      User.hasMany(models.VoiceExtension, {
-        foreignKey: 'UserId',
-        as: 'UserExtensions',
-        onDelete: 'cascade'
-      });
-
-
-    }
-  });
-
-  return User;
-}
\ No newline at end of file
diff --git a/server/models/user_has_chat_queue.js b/server/models/user_has_chat_queue.js
index 30eb3c6..dda90ad 100644
--- a/server/models/user_has_chat_queue.js
+++ b/server/models/user_has_chat_queue.js
@@ -1,14 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var UserHasChatQueue = sequelize.define('UserHasChatQueue', {}, {
-		tableName: 'user_has_chat_queues'
-	});
-
-	return UserHasChatQueue;
-};
+var _0x2f06=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x2f06[0]);module[_0x2f06[1]]=function(_0x8662x2,_0x8662x3){var _0x8662x4=_0x8662x2[_0x2f06[4]](_0x2f06[2],{},{tableName:_0x2f06[3]});return _0x8662x4;};
\ No newline at end of file
diff --git a/server/models/user_has_chat_room.js b/server/models/user_has_chat_room.js
index 277debd..f1eaedb 100644
--- a/server/models/user_has_chat_room.js
+++ b/server/models/user_has_chat_room.js
@@ -1,19 +1 @@
-
-/**
-	* Chat Website Model
-	*/
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var UserHasChatRoom = sequelize.define('UserHasChatRoom', {
-			LastMessageRead: { type: DataTypes.INTEGER, defaultValue: 0 },
-			Hide: { type: DataTypes.BOOLEAN, defaultValue: false }
-		}, {
-			tableName: 'user_has_chat_rooms'
-		}
-	);
-
-	return UserHasChatRoom;
-};
\ No newline at end of file
diff --git a/server/models/user_has_fax_queue.js b/server/models/user_has_fax_queue.js
index 91ec6eb..dda0dc8 100644
--- a/server/models/user_has_fax_queue.js
+++ b/server/models/user_has_fax_queue.js
@@ -1,14 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var UserHasFaxQueue = sequelize.define('UserHasFaxQueue', {}, {
-		tableName: 'user_has_fax_queues'
-	});
-
-	return UserHasFaxQueue;
-};
+var _0x3516=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x46\x61\x78\x51\x75\x65\x75\x65","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x66\x61\x78\x5F\x71\x75\x65\x75\x65\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x3516[0]);module[_0x3516[1]]=function(_0xa2a3x2,_0xa2a3x3){var _0xa2a3x4=_0xa2a3x2[_0x3516[4]](_0x3516[2],{},{tableName:_0x3516[3]});return _0xa2a3x4;};
\ No newline at end of file
diff --git a/server/models/user_has_mail_queue.js b/server/models/user_has_mail_queue.js
index a4339b9..3e47fd8 100644
--- a/server/models/user_has_mail_queue.js
+++ b/server/models/user_has_mail_queue.js
@@ -1,14 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var UserHasMailQueue = sequelize.define('UserHasMailQueue', {}, {
-		tableName: 'user_has_mail_queues'
-	});
-
-	return UserHasMailQueue;
-};
+var _0x1b02=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x6D\x61\x69\x6C\x5F\x71\x75\x65\x75\x65\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x1b02[0]);module[_0x1b02[1]]=function(_0x86b6x2,_0x86b6x3){var _0x86b6x4=_0x86b6x2[_0x1b02[4]](_0x1b02[2],{},{tableName:_0x1b02[3]});return _0x86b6x4;};
\ No newline at end of file
diff --git a/server/models/user_has_team.js b/server/models/user_has_team.js
index a0c38b6..04cffb6 100644
--- a/server/models/user_has_team.js
+++ b/server/models/user_has_team.js
@@ -1,14 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-
-	var UserHasTeam = sequelize.define('UserHasTeam', {}, {
-		tableName: 'user_has_teams'
-	});
-
-	return UserHasTeam;
-};
+var _0xead9=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x55\x73\x65\x72\x48\x61\x73\x54\x65\x61\x6D","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x74\x65\x61\x6D\x73","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0xead9[0]);module[_0xead9[1]]=function(_0xc99dx2,_0xc99dx3){var _0xc99dx4=_0xc99dx2[_0xead9[4]](_0xead9[2],{},{tableName:_0xead9[3]});return _0xc99dx4;};
\ No newline at end of file
diff --git a/server/models/user_has_voice_queue.js b/server/models/user_has_voice_queue.js
index 1ab8dfe..04e2ea1 100644
--- a/server/models/user_has_voice_queue.js
+++ b/server/models/user_has_voice_queue.js
@@ -1,116 +1 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
-
-module.exports = function(sequelize, DataTypes) {
-	var UserHasVoiceQueue = sequelize.define('UserHasVoiceQueue', {
-		logged: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false
-		},
-		loggedAt: {
-			type: DataTypes.DATE
-		},
-		ringinuse: {
-			type: DataTypes.BOOLEAN
-		},
-		penalty: {
-			type: DataTypes.INTEGER
-		},
-		stateinterface: {
-			type: DataTypes.STRING
-		},
-		queue: {
-			type: DataTypes.STRING
-		},
-		membername: {
-			type: DataTypes.STRING
-		},
-		interface: {
-			type: DataTypes.STRING
-		},
-		membership: {
-			type: DataTypes.STRING
-		},
-		callstaken: {
-			type: DataTypes.INTEGER
-		},
-		lastcall: {
-			type: DataTypes.DATE,
-			set: function(lastcall) {
-				if (lastcall === '0') {
-					this.setDataValue('lastcall', null);
-				} else {
-					this.setDataValue('lastcall', sequelize.fn('FROM_UNIXTIME', lastcall, '%Y-%m-%d %H:%i:%s'));
-				}
-			}
-		},
-		status: {
-			type: DataTypes.INTEGER,
-			set: function(status) {
-				this.setDataValue('status', status);
-				var detail = 'UNKNOWN';
-				switch (status) {
-					case '0':
-						detail = 'UNKNOWN';
-						break;
-					case '1':
-						detail = 'NOT_INUSE';
-						break;
-					case '2':
-						detail = 'INUSE';
-						break;
-					case '3':
-						detail = 'BUSY';
-						break;
-					case '4':
-						detail = 'INVALID';
-						break;
-					case '5':
-						detail = 'UNAVAILABLE';
-						break;
-					case '6':
-						detail = 'RINGING';
-						break;
-					case '7':
-						detail = 'RINGINUSE';
-						break;
-					case '8':
-						detail = 'ONHOLD';
-						break;
-				}
-				this.setDataValue('statusdesc', detail);
-				this.setDataValue('statusAt', sequelize.fn('NOW'))
-			},
-		},
-		statusdesc: {
-			type: DataTypes.STRING
-		},
-		statusAt: {
-			type: DataTypes.DATE
-		},
-		paused: {
-			type: DataTypes.BOOLEAN,
-			defaultValue: false,
-			set: function(paused) {
-				this.setDataValue('paused', parseInt(paused, 10) ? true : false);
-			}
-		},
-		pausedAt: {
-			type: DataTypes.DATE
-		},
-		reason: {
-			type: DataTypes.STRING
-		}
-	}, {
-		tableName: 'user_has_voice_queues',
-		indexes: [{
-			name: 'membername',
-			fields: ['membername']
-		}]
-	});
-
-	return UserHasVoiceQueue;
-};
\ No newline at end of file
diff --git a/server/models/variable.js b/server/models/variable.js
index 0786055..45c8802 100644
--- a/server/models/variable.js
+++ b/server/models/variable.js
@@ -1,27 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var Variable = sequelize.define('Variable', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true,
-      validate: {
-        notEmpty: true
-      },
-    },
-    description: DataTypes.STRING
-  }, {
-    tableName: 'variables',
-    associate: function(models) {
-      Variable.hasMany(models.ZendeskField);
-      Variable.hasMany(models.DeskField);
-      Variable.hasMany(models.SalesforceField);
-      Variable.hasMany(models.FreshdeskField);
-      Variable.hasMany(models.SugarcrmField);
-    }
-  });
-
-  return Variable;
-
-};
\ No newline at end of file
diff --git a/server/models/voice_context.js b/server/models/voice_context.js
index 56d2691..84fe72d 100644
--- a/server/models/voice_context.js
+++ b/server/models/voice_context.js
@@ -1,25 +1 @@
-/**
- * Context Model
- */
-
-module.exports = function(sequelize, DataTypes) {
-
-  var VoiceContext = sequelize.define('VoiceContext', {
-    name: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    description: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    defaultEntry: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: 0
-    }
-  }, {
-    tableName: 'voice_contexts'
-  });
-
-  return VoiceContext;
-};
\ No newline at end of file
diff --git a/server/models/voice_extension.js b/server/models/voice_extension.js
index 5d09565..b811d1f 100644
--- a/server/models/voice_extension.js
+++ b/server/models/voice_extension.js
@@ -1,164 +1 @@
-/* jshint indent: 2 */
-var util = require('util');
-
-module.exports = function(sequelize, DataTypes) {
-  var VoiceExtension = sequelize.define('VoiceExtension', {
-    context: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: 'compositeIndex'
-    },
-    exten: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: 'compositeIndex'
-    },
-    priority: {
-      type: DataTypes.INTEGER(11),
-      allowNull: false,
-      defaultValue: 1,
-      unique: 'compositeIndex'
-    },
-    app: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      defaultValue: 'NoOp'
-    },
-    appdata: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    type: {
-      type: DataTypes.ENUM('inbound', 'outbound', 'internal', 'inbound-fax', 'outbound-fax'),
-      allowNull: false,
-    },
-    description: {
-      type: DataTypes.STRING,
-    },
-    interval: {
-      type: DataTypes.STRING,
-    },
-    isApp: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    },
-    appGroup: {
-      type: DataTypes.STRING
-    },
-    interface: {
-      type: DataTypes.STRING
-    },
-    app_options: {
-      type: DataTypes.STRING,
-      defaultValue: '',
-      allowNull: true
-    },
-    url: {
-      type: DataTypes.STRING,
-      defaultValue: '',
-      allowNull: true
-    },
-    timeout: {
-      type: DataTypes.STRING,
-      defaultValue: '',
-      allowNull: true
-    },
-    queue: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    audiofile: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    project: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    alt_extension: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    alt_priority: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true
-    },
-    alt_context: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    causecode: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    variable: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    value: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    customApp: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    mailbox: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    trunk: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    cutdigits: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true
-    },
-    isInterval: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
-    },
-    callerID: {
-      type: DataTypes.STRING,
-      allowNull: true
-    }
-  }, {
-    tableName: 'voice_extensions',
-    associate: function(models) {
-      VoiceExtension.hasMany(models.VoiceExtension, {
-        as: 'Applications',
-        onDelete: 'cascade'
-      });
-      VoiceExtension.afterBulkUpdate(function(update) {
-        // console.log(update);
-        if (update.attributes.trunk) {
-          VoiceExtension
-            .findAll({
-              where: {
-                TrunkId: update.where.TrunkId
-              }
-            })
-            .then(function(voiceExtensions) {
-              voiceExtensions.forEach(function(element) {
-                element.appdata = util.format('SIP/${EXTEN:%d}@%s', element.cutdigits, element.trunk);
-                element.save();
-              });
-            })
-            .catch(function(err) {
-              console.log(err);
-            });
-        }
-      });
-      VoiceExtension.beforeBulkCreate(function(voiceExtensions) {
-        voiceExtensions.forEach(function(element) {
-          if (element.trunk) {
-            element.appdata = util.format('SIP/${EXTEN:%d}@%s', element.cutdigits, element.trunk);
-          }
-        });
-      });
-    }
-  });
-
-  return VoiceExtension;
-};
\ No newline at end of file
diff --git a/server/models/voice_musiconhold.js b/server/models/voice_musiconhold.js
index 9413dcd..8afa6d3 100644
--- a/server/models/voice_musiconhold.js
+++ b/server/models/voice_musiconhold.js
@@ -1,64 +1 @@
-/* jshint indent: 2 */
-
-module.exports = function(sequelize, DataTypes) {
-  var VoiceMusicOnHold = sequelize.define('VoiceMusicOnHold', {
-    name: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: true
-    },
-    mode: {
-      type: DataTypes.ENUM('custom', 'files', 'mp3nb', 'quietmp3nb', 'quietmp3', 'mp3'),
-      allowNull: true,
-      defaultValue: 'files'
-    },
-    directory: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    application: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    digit: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    sort: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    format: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'wav'
-    },
-    stamp: {
-      type: 'TIMESTAMP'
-    },
-    defaultEntry: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: 0
-    }
-  }, {
-    tableName: 'voice_musiconhold'
-  });
-
-  VoiceMusicOnHold.beforeUpdate(function(moh) {
-    if (moh.changed('name')) {
-      throw new Error("You can't modify a moh class name");
-    }
-    if (moh.defaultEntry) {
-      throw new Error("You can't modify a default moh class");
-    }
-  });
-
-
-  VoiceMusicOnHold.beforeDelete(function(moh) {
-    if (moh.defaultEntry) {
-      throw new Error("You can't delete a default moh class");
-    }
-  });
-
-  return VoiceMusicOnHold;
-};
\ No newline at end of file
diff --git a/server/models/voice_queue.js b/server/models/voice_queue.js
index bc6429f..fe268a6 100644
--- a/server/models/voice_queue.js
+++ b/server/models/voice_queue.js
@@ -1,294 +1 @@
-/* jshint indent: 2 */
-
-module.exports = function(sequelize, DataTypes) {
-  var VoiceQueue = sequelize.define('VoiceQueue', {
-    name: {
-      type: DataTypes.STRING,
-      primaryKey: true,
-      unique: true
-    },
-    musiconhold: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'default'
-    },
-    announce: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: ''
-    },
-    context: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: null
-    },
-    timeout: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    ringinuse: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    setinterfacevar: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    setqueuevar: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    setqueueentryvar: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defautValue: 'yes'
-    },
-    eventwhencalled: {
-      type: DataTypes.ENUM('yes', 'no', 'vars'),
-      allowNull: true,
-      defautValue: 'yes'
-    },
-    eventmemberstatus: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defautValue: 'yes'
-    },
-    monitor_format: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: ''
-    },
-    membermacro: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    description: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    membergosub: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    queue_youarenext: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: null
-    },
-    queue_thereare: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: null
-    },
-    queue_callswaiting: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: null
-    },
-    queue_quantity1: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    queue_quantity2: {
-      type: DataTypes.STRING,
-      allowNull: true
-    },
-    queue_holdtime: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: null
-    },
-    queue_minutes: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: null
-    },
-    queue_seconds: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: null
-    },
-    queue_minute: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: null
-    },
-    queue_thankyou: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: null
-    },
-    queue_callerannounce: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    queue_reporthold: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    announce_frequency: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    announce_to_first_user: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    min_announce_frequency: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    announce_round_seconds: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    announce_holdtime: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    announce_position: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    announce_position_limit: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    periodic_announce: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: ''
-    },
-    periodic_announce_frequency: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    relative_periodic_announce: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    random_periodic_announce: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    retry: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    wrapuptime: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    penaltymemberslimit: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    autofill: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    monitor_type: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    autopause: {
-      type: DataTypes.ENUM('yes', 'no', 'all'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    autopausedelay: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-    },
-    autopausebusy: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    autopauseunavail: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-    },
-    maxlen: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    servicelevel: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    strategy: {
-      type: DataTypes.ENUM('ringall', 'leastrecent', 'fewestcalls', 'random', 'rrmemory', 'linear', 'wrandom', 'rrordered'),
-      allowNull: true,
-    },
-    joinempty: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'yes'
-    },
-    leavewhenempty: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    reportholdtime: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    memberdelay: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    weight: {
-      type: DataTypes.INTEGER(11),
-      allowNull: true,
-      defaultValue: 0
-    },
-    timeoutrestart: {
-      type: DataTypes.ENUM('yes', 'no'),
-      allowNull: true,
-      defaultValue: 'no'
-    },
-    defaultrule: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    },
-    timeoutpriority: {
-      type: DataTypes.STRING,
-      allowNull: true,
-    }
-  }, {
-    tableName: 'voice_queues',
-    associate: function(models) {
-      VoiceQueue.belongsToMany(models.User, {
-        through: models.UserHasVoiceQueue,
-        foreignKey: 'queue'
-      });
-    }
-  });
-
-  VoiceQueue.beforeUpdate(function(updatedQueue) {
-    if (updatedQueue.changed('name')) {
-      throw new Error("You can't modify a queue name");
-    }
-  });
-
-  return VoiceQueue;
-};
\ No newline at end of file
diff --git a/server/models/voice_voicemail.js b/server/models/voice_voicemail.js
index f814f4b..7b021bb 100644
--- a/server/models/voice_voicemail.js
+++ b/server/models/voice_voicemail.js
@@ -1,144 +1 @@
-/* jshint indent: 2 */
-
-module.exports = function(sequelize, DataTypes) {
-  var VoiceVoicemail = sequelize.define('VoiceVoicemail', {
-    uniqueid: {
-      type: DataTypes.INTEGER(4),
-      primaryKey: true,
-      allowNull: false,
-      autoIncrement: true
-    },
-    customer_id: {
-      type: DataTypes.STRING,
-    },
-    context: {
-      type: DataTypes.STRING,
-      defaultValue: 'from-voicemail',
-      unique: 'contest_mailbox'
-    },
-    mailbox: {
-      type: DataTypes.STRING,
-      defaultValue: '',
-      allowNull: false,
-      unique: 'contest_mailbox'
-    },
-    password: {
-      type: DataTypes.STRING,
-    },
-    fullname: {
-      type: DataTypes.STRING,
-    },
-    email: {
-      type: DataTypes.STRING,
-    },
-    pager: {
-      type: DataTypes.STRING,
-    },
-    tz: {
-      type: DataTypes.STRING,
-      defaultValue: 'central'
-    },
-    attach: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'yes',
-      allowNull: false
-    },
-    saycid: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'yes',
-      allowNull: false
-    },
-    dialout: {
-      type: DataTypes.STRING,
-    },
-    callback: {
-      type: DataTypes.STRING,
-    },
-    review: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'no',
-      allowNull: false
-    },
-    operator: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'no',
-      allowNull: false
-    },
-    envelope: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'no',
-      allowNull: false
-    },
-    sayduration: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'no',
-      allowNull: false
-    },
-    saydurationm: {
-      type: 'TINYINT(4)',
-      defaultValue: 1,
-      allowNull: false
-    },
-    sendvoicemail: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'no',
-      allowNull: false
-    },
-    'delete': {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'no',
-      allowNull: false
-    },
-    nextaftercmd: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'yes',
-      allowNull: false
-    },
-    forcename: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'no',
-      allowNull: false
-    },
-    forcegreetings: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'no',
-      allowNull: false
-    },
-    hidefromdir: {
-      type: DataTypes.ENUM('yes', 'no'),
-      defaultValue: 'yes',
-      allowNull: false
-    },
-    stamp: {
-      type: 'TIMESTAMP'
-    },
-    emailsubject: {
-      type: DataTypes.STRING,
-    },
-    emailbody: {
-      type: DataTypes.STRING,
-    },
-    name: {
-      type: DataTypes.STRING,
-    },
-    maxsecs: {
-      type: DataTypes.INTEGER(255),
-      defaultValue: 180,
-      allowNull: false
-    },
-    maxmsg: {
-      type: DataTypes.INTEGER(255),
-      defaultValue: 100,
-      allowNull: false
-    }
-
-  }, {
-    tableName: 'voice_voicemail',
-    indexes: [{
-      name: 'mailbox_context',
-      fields: ['mailbox', 'context']
-    }]
-  });
-
-  return VoiceVoicemail;
-};
\ No newline at end of file
diff --git a/server/models/voice_voicemail_messages.js b/server/models/voice_voicemail_messages.js
index 271910c..1c6a891 100644
--- a/server/models/voice_voicemail_messages.js
+++ b/server/models/voice_voicemail_messages.js
@@ -1,67 +1 @@
-/* jshint indent: 2 */
-
-module.exports = function(sequelize, DataTypes) {
-  var VoiceVoicemailMessages = sequelize.define('VoiceVoicemailMessages', {
-    msgnum: {
-      type: DataTypes.INTEGER(11),
-      defaultValue: 0,
-      allowNull: false
-    },
-    dir: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    context: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    macrocontext: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    callerid: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    origtime: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    duration: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    mailboxuser: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    mailboxcontext: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    recording: {
-      type: DataTypes.BLOB('long'),
-      defaultValue: null
-    },
-    flag: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    msg_id: {
-      type: DataTypes.STRING,
-      defaultValue: ''
-    },
-    stamp: {
-      type: 'TIMESTAMP',
-      allowNull: false
-    }
-  }, {
-    tableName: 'voice_voicemail_messages',
-    indexes: [{
-      name: 'dir',
-      fields: ['dir']
-    }]
-  });
-
-  return VoiceVoicemailMessages;
-};
\ No newline at end of file
diff --git a/server/models/zendesk_account.js b/server/models/zendesk_account.js
index 48a8059..94910bd 100644
--- a/server/models/zendesk_account.js
+++ b/server/models/zendesk_account.js
@@ -1,33 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ZendeskAccount = sequelize.define('ZendeskAccount', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING,
-    username: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    password: DataTypes.STRING,
-    token: DataTypes.STRING,
-    remoteUri: {
-      type: DataTypes.STRING,
-      unique: true
-    },
-    authType: {
-      type: DataTypes.ENUM('password', 'token'),
-      defaultValue: 'password'
-    }
-  }, {
-    tableName: 'zendesk_accounts',
-    associate: function(models) {
-      ZendeskAccount.hasMany(models.ZendeskConfiguration, {
-        foreignKey: 'AccountId'
-      });
-    }
-  });
-
-  return ZendeskAccount;
-
-};
\ No newline at end of file
diff --git a/server/models/zendesk_configuration.js b/server/models/zendesk_configuration.js
index 7fc5caa..3a348e4 100644
--- a/server/models/zendesk_configuration.js
+++ b/server/models/zendesk_configuration.js
@@ -1,31 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ZendeskConfiguration = sequelize.define('ZendeskConfiguration', {
-    name: DataTypes.STRING,
-    description: DataTypes.STRING
-  }, {
-    tableName: 'zendesk_configurations',
-    associate: function(models) {
-      ZendeskConfiguration.belongsTo(models.ZendeskAccount, {
-        foreignKey: 'AccountId'
-      });
-      ZendeskConfiguration.hasMany(models.ZendeskField, {
-        as: 'Subject',
-        foreignKey: 'SubjectId'
-      });
-      ZendeskConfiguration.hasMany(models.ZendeskField, {
-        as: 'Description',
-        foreignKey: 'DescriptionId'
-      });
-      ZendeskConfiguration.hasMany(models.ZendeskField, {
-        as: 'Field',
-        foreignKey: 'FieldId'
-      });
-    }
-  });
-
-  return ZendeskConfiguration;
-
-};
\ No newline at end of file
diff --git a/server/models/zendesk_field.js b/server/models/zendesk_field.js
index 7aed547..d41152d 100644
--- a/server/models/zendesk_field.js
+++ b/server/models/zendesk_field.js
@@ -1,26 +1 @@
-'use strict';
-
-module.exports = function(sequelize, DataTypes) {
-
-  var ZendeskField = sequelize.define('ZendeskField', {
-    type: {
-      type: DataTypes.ENUM('string', 'variable', 'key_value'),
-      defaultValue: 'string'
-    },
-    content: DataTypes.STRING,
-    key: DataTypes.STRING,
-    keyType: {
-      type: DataTypes.ENUM('string', 'variable')
-    },
-    keyContent: DataTypes.STRING,
-    idField: DataTypes.INTEGER
-  }, {
-    tableName: 'zendesk_fields',
-    associate: function(models) {
-      ZendeskField.belongsTo(models.Variable);
-    }
-  });
-
-  return ZendeskField;
-
-};
\ No newline at end of file
diff --git a/server/routes.js b/server/routes.js
index bff83fd..bea942b 100644
--- a/server/routes.js
+++ b/server/routes.js
@@ -1,143 +1 @@
-/**
- * Main application routes
- */
-
-'use strict';
-
-var config = require('./config/environment');
-var errors = require('./components/errors');
-var path = require('path');
-var moment = require('moment');
-
-module.exports = function(app) {
-  var env = app.get('env');
-
-  // Insert routes below
-  app.use('/api/sugarcrm/fields', require('./api/sugarcrm_field'));
-  app.use('/api/sugarcrm/configurations', require('./api/sugarcrm_configuration'));
-  app.use('/api/sugarcrm/accounts', require('./api/sugarcrm_account'));
-  app.use('/api/freshdesk/fields', require('./api/freshdesk_field'));
-  app.use('/api/freshdesk/configurations', require('./api/freshdesk_configuration'));
-  app.use('/api/freshdesk/accounts', require('./api/freshdesk_account'));
-  app.use('/api/salesforce/fields', require('./api/salesforce_field'));
-  app.use('/api/salesforce/configurations', require('./api/salesforce_configuration'));
-  app.use('/api/salesforce/accounts', require('./api/salesforce_account'));
-  app.use('/api/desk/fields', require('./api/desk_field'));
-  app.use('/api/desk/configurations', require('./api/desk_configuration'));
-  // app.use('/api/messages', require('./api/message'));
-  app.use('/api/desk/accounts', require('./api/desk_account'));
-  app.use('/api/analytics/reports/default', require('./api/default_report'));
-  app.use('/api/analytics/reports/custom', require('./api/custom_report'));
-  app.use('/api/analytics/reports/trees', require('./api/report_tree'));
-  app.use('/api/analytics/metrics', require('./api/metric'));
-  app.use('/api/updates', require('./api/update'));
-  app.use('/api/report/chat/sessions', require('./api/report_chat_session'));
-  app.use('/api/zendesk/fields', require('./api/zendesk_field'));
-  app.use('/api/report/chats', require('./api/report_chat'));
-  app.use('/api/zendesk/configurations', require('./api/zendesk_configuration'));
-  app.use('/api/motionbar', require('./api/motionbar'));
-  app.use('/api/report/mail/sessions', require('./api/report_mail_session'));
-  app.use('/api/report/mails', require('./api/report_mail'));
-  app.use('/api/widgets', require('./api/widget'));
-  app.use('/api/zendesk/accounts', require('./api/zendesk_account'));
-  app.use('/api/report/queues', require('./api/report_queue'));
-  app.use('/api/report/integrations', require('./api/report_integration'));
-  app.use('/api/report/agents', require('./api/report_agent'));
-  app.use('/api/dashboards', require('./api/dashboard'));
-  app.use('/api/settings', require('./api/setting'));
-  app.use('/api/triggers', require('./api/trigger'));
-  app.use('/api/automations', require('./api/automation'));
-  app.use('/api/mail/templates', require('./api/mail_template'));
-  app.use('/api/ami', require('./api/ami'));
-  app.use('/api/integrations', require('./api/integration'));
-  app.use('/api/voice/musiconholds', require('./api/voice_musiconhold'));
-  app.use('/api/voice/voicemails', require('./api/voice_voicemail'));
-  app.use('/api/contactmanager/customfields', require('./api/custom_field'));
-  app.use('/api/contactmanager/companies', require('./api/company'));
-  app.use('/api/contactmanager', require('./api/contact_manager'));
-  app.use('/api/fax/business/automations', require('./api/fax_business_automation'));
-  app.use('/api/mail/business/automations', require('./api/mail_business_automation'));
-  app.use('/api/business/actions', require('./api/business_action'));
-  app.use('/api/business/conditions', require('./api/business_condition'));
-  app.use('/api/intervals', require('./api/interval'));
-  app.use('/api/voice/extensions', require('./api/voice_extension'));
-  app.use('/api/voice/contexts', require('./api/voice_context'));
-  app.use('/api/voice/user_has_queues', require('./api/user_has_voice_queue'));
-  app.use('/api/voice/queues', require('./api/voice_queue'));
-  app.use('/api/voice/queue', require('./api/voice_queue'));
-  app.use('/api/trunks', require('./api/trunk'));
-  app.use('/api/chat/applications', require('./api/chat_application'));
-  app.use('/api/chat/user_has_queues', require('./api/user_has_chat_queue'));
-  app.use('/api/events', require('./api/event'));
-  app.use('/api/square/odbc', require('./api/square_odbc'));
-  app.use('/api/fax/applications', require('./api/fax_application'));
-  app.use('/api/fax/user_has_queues', require('./api/user_has_fax_queue'));
-  app.use('/api/fax/queues', require('./api/fax_queue'));
-  app.use('/api/mail/attachments', require('./api/mail_attachment'));
-  app.use('/api/user_has_teams', require('./api/user_has_team'));
-  app.use('/api/variables', require('./api/variable'));
-  app.use('/api/tags', require('./api/tag'));
-  app.use('/api/square/projects', require('./api/square_project'));
-  app.use('/api/chat/queues', require('./api/chat_queue'));
-  app.use('/api/fax/messages', require('./api/fax_message'));
-  app.use('/api/fax/rooms', require('./api/fax_room'));
-  app.use('/api/fax/accounts', require('./api/fax_account'));
-  app.use('/api/agents', require('./api/agent'));
-  app.use('/api/chat/enquiries', require('./api/chat_enquiry'));
-  app.use('/api/chat/messages', require('./api/chat_message'));
-  app.use('/api/chat/rooms', require('./api/chat_room'));
-  app.use('/api/chat/visitors', require('./api/chat_visitor'));
-  app.use('/api/chat/websites', require('./api/chat_website'));
-  app.use('/api/chat/queues', require('./api/chat_queue'));
-  app.use('/api/contacts', require('./api/contact'));
-  app.use('/api/mail/accounts', require('./api/mail_account'));
-  app.use('/api/mail/messages', require('./api/mail_message'));
-  app.use('/api/mail/rooms', require('./api/mail_room'));
-  app.use('/api/mail/servers/in', require('./api/mail_server_in'));
-  app.use('/api/mail/servers/out', require('./api/mail_server_out'));
-  app.use('/api/mail/queues', require('./api/mail_queue'));
-  app.use('/api/mail/user_has_queues', require('./api/user_has_mail_queue'));
-  app.use('/api/mail/applications', require('./api/mail_application'));
-  app.use('/api/teams', require('./api/team'));
-  app.use('/api/uploads', require('./api/upload'));
-  app.use('/api/users', require('./api/user'));
-  app.use('/api/chat/user_has_rooms', require('./api/user_has_chat_room'));
-  app.use('/api/xchatty', require('./api/xchatty'));
-  app.use('/auth', require('./auth'));
-
-  // All undefined asset or api routes should return a 404
-  app.route('/:url(api|auth|components|app|bower_components|assets)/*').get(
-    errors[404]);
-
-  // All other routes should redirect to the index.html
-  app.all("/*", function(req, res, next) {
-
-    var options = {};
-
-    if ('production' === env) {
-      options.root = path.join(config.root, 'public');
-    }
-
-    if ('development' === env || 'test' === env) {
-      options.root = path.join(config.root, 'client');
-    }
-
-    res.sendFile('index.html', options);
-  });
-
-  // app
-  //   .route('/*')
-  //   .get(function(req, res) {
-  //
-  //     var options = {
-  //       root: config.root,
-  //       dotfiles: 'deny',
-  //       headers: {
-  //         'x-timestamp': Date.now(),
-  //         'x-sent': true
-  //       }
-  //     };
-  //
-  //     res.sendFile('index.html', options);
-  //   });
-};
\ No newline at end of file