{"size": 1571, "ext": "js", "max_stars_repo_path": "resources/assets/js/controllers/project/projectNew.js", "max_stars_repo_name": "jaysongyn/CodeProject", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "resources/assets/js/controllers/project/projectNew.js", "max_issues_repo_name": "jaysongyn/CodeProject", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "resources/assets/js/controllers/project/projectNew.js", "max_forks_repo_name": "jaysongyn/CodeProject", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.0612244898, "max_line_length": 110, "alphanum_fraction": 0.4022915341}
angular.module('app.controllers')
    .controller('ProjectNewtController', ['$scope', '$location', 'Project', 'Client', 'appConfig', '$cookies',
        function ($scope, $location, Project, Client, appConfig, $cookies) {
            $scope.project = new Project();
            $scope.clients = new Client.query();
            $scope.status = appConfig.project.status;


            $scope.due_date = {
                status: {
                    opened: false
                }
            };

            $scope.open = function($event){
                $scope.due_date.status.opened = true;
            };



            $scope.formatName = function (id) {
                if(id){
                    for (var i in $scope.clients) {
                        if ($scope.clients[i].id == id) {
                            return $scope.clients[i].name
                        }
                    }
                }
                return '';

            }
            $scope.getClients = function (name) {
              return Client.query({
                  search:name,
                  searchFields:'name:like'
              }).$promise;
            }
            $scope.save = function () {
                if ($scope.form.$valid) {
                    $scope.project.owner_id = $cookies.getObject('user').id;
                    $scope.project.$save().then(function () {
                        $location.path('/projects');
                    });
                } else {
                    console.log("aqui");
                }
            }
        }]);
