/**
 * Created by KLE-Talha on 23/02/16.
 */
var util = require('util');
var async = require('async');
var mongoose = require('mongoose')
var utils = rekuire('/lib/utils')
var extend = require('util')._extend
var Section = mongoose.model('Section');
var SectionGrup = mongoose.model('SectionGrup');
var SectionType = mongoose.model('SectionType');

exports.model = mongoose.model('SectionType');
exports.title = 'Tip';
exports.singularName = 'sectionType';
exports.pluralName = 'sectionTypes';
var BaseController = require('elderwand').BaseController;
BaseController.inherit(exports);
  

exports.super.loadRelatedData = exports.loadRelatedData
 exports.loadRelatedData = function(data, req, res, callback){  
  exports.super.loadRelatedData(data, req, res, function(newData){
    async.parallel([
      function(next){
        Section.list({}, function(err, result){
          newData.sections = result;
          next()
        });
      },
      function(next){
        SectionGrup.list({}, function(err, result){
          newData.sectionGrups = result;
          next()
        });
      },
      function(next){
        SectionType.list({}, function(err, result){
          newData.sectionTypes = result;
          next()
        });
      }
    ], function(err){
      if(req.params.ownerId){
        newData.ownerId = req.params.ownerId
      }
      callback(newData); 
    }) 
  });
 }    
    
