<commit_before>'use strict';

app.controller('employeeCtrl', ['$scope', 'Upload', '$timeout', '$http', 'QLNS', function($scope, Upload, $timeout, $http, QLNS){
    
    $scope.employee = {
        Ho: '',
        Ten: '',
        NgaySinh: '',
        DiaChi: '',
        GioiTinh: '',
        DienThoai: '',
        Email: '',
        MaSoBaoHiem: '',
        TrinhDo: '',
        TonGiao: '',
        ChungChiChuyenNghanh: '',
        ChungChiAnhVan: '',
        imgEmployPath: '',
        CVPath: '',
        ScoreTablePath: '',
        CertificatePath: '',
        HouseholdPath: '',
        DiplomaPath: '',
        HealthCertificationPath: '',
        PhongBan: '',
        ChucVu: '',
        maPhongBan: '',
        maChucVu: '',
        maChuyenNghanh: '',
        ChuyenNghanh: '',
        TuNgay: '',
        DenNgay: '',
        MaNhanVien: ''
    };

var clearEmployee = function(){
        $scope.employee = {
        Ho: '',
        Ten: '',
        NgaySinh: '',
        DiaChi: '',
        GioiTinh: '',
        DienThoai: '',
        Email: '',
        MaSoBaoHiem: '',
        TrinhDo: '',
        TonGiao: '',
        ChungChiChuyenNghanh: '',
        ChungChiAnhVan: '',
        imgEmployPath: '',
        CVPath: '',
        ScoreTablePath: '',
        CertificatePath: '',
        HouseholdPath: '',
        DiplomaPath: '',
        HealthCertificationPath: '',
        PhongBan: '',
        ChucVu: '',
        maPhongBan: '',
        maChucVu: '',
        maChuyenNghanh: '',
        ChuyenNghanh: '',
        TuNgay: '',
        DenNgay: '',
        MaNhanVien: ''
    };
    $scope.CVs[0].name = '';
    $scope.ScoreTables[0].name = '';
    $scope.Certificates[0].name = '';
    $scope.Households[0].name = '';
    $scope.Diplomas[0].name = '';
    $scope.HealthCertifications[0].name = '';
};
    // Lưu
    $scope.Save = function(){     
        //console.log($scope.employee);
        if(!checkDepartment()){
            alert('Vui lòng chọn Phòng Ban');
        } else if(!checkRole()){
            alert('VUi lòng chọn Chức Vụ');
        } else if(!checkMajor()){
            alert('Vui lòng chọn Chuyên Nghành');
        } else if(!checkGender()){
            alert('Vui lòng chọn Giới Tính');
        } else{
            QLNS.employee.POST($scope.employee).then(function(res){
                alert(res.data);
                clearEmployee();
                refesh();
            });
        }
    };

    $scope.selectDepartment = function(mpb, pb){
        $scope.employee.maPhongBan = mpb;
        $scope.employee.PhongBan = pb;
        console.log(pb);
    };

    $scope.selectRole = function(mcv, cv){
        $scope.employee.maChucVu = mcv;
        $scope.employee.ChucVu = cv;
        console.log(cv);
    };

    $scope.selectMajoring = function(mcn, cn){
        $scope.employee.maChuyenNghanh = mcn;
        $scope.employee.ChuyenNghanh = cn;
        console.log(cn);
    };

    $scope.selectGender = function(genderName){
        if(genderName === 'Nam'){
            $scope.employee.GioiTinh = 1;
            $scope.gender = genderName;
        } else if(genderName === 'Nữ'){
            $scope.employee.GioiTinh = 0;
            $scope.gender = genderName;
        }
    };

    //Refesh Add Employee page
    var refesh = function(){
        $scope.employee.PhongBan = 'Chọn';
        $scope.employee.ChucVu = 'Chọn';
        $scope.employee.ChuyenNghanh = 'Chọn';
        $scope.gender = 'Chọn';
        QLNS.department.GETNAME().then(function(res){
            //console.log(res.data);
            $scope.departments = res.data;
        });
        QLNS.role.GETNAME().then(function(res){
            //console.log(res.data);
            $scope.roles = res.data;
        });
        QLNS.majoring.GET().then(function(res){
            //console.log(res.data);
            $scope.majoring = res.data;
        });
    };
    refesh();

    // Check Phòng Ban
    var checkDepartment = function(){
        if($scope.employee.PhongBan === 'Chọn' || $scope.employee.PhongBan === ''){
            return false;
        } else {
            return true;
        }
    };

    // check Chức Vụ
    var checkRole = function(){
        if($scope.employee.ChucVu === 'Chọn' || $scope.employee.ChucVu === ''){
            return false;
        } else {
            return true;
        }
    };

    // check Chuyên Nghành
    var checkMajor = function(){
        if($scope.employee.ChuyenNghanh === 'Chọn' || $scope.employee.ChuyenNghanh === ''){
            return false;
        } else {
            return true;
        }
    };

    // check Giới Tính
    var checkGender = function(){
        if($scope.gender === 'Chọn' || $scope.gender === ''){
            return false;
        } else {
            return true;
        }
    }

    // Image Employee
    $scope.$watch('imgEmploys', function () {
        //console.log($scope.imgEmploys);  
        $scope.uploadImage($scope.imgEmploys);
    });
    $scope.$watch('imgEmploy', function () {
        if ($scope.imgEmploy != null) {
            //console.log($scope.files);
            $scope.imgEmploys = [$scope.imgEmploy]; 
        }
    });
    $scope.logimg = '';<commit_msg>Simple if statement<commit_after>'use strict';

app.controller('employeeCtrl', ['$scope', 'Upload', '$timeout', '$http', 'QLNS', function($scope, Upload, $timeout, $http, QLNS){
    
    $scope.employee = {
        Ho: '',
        Ten: '',
        NgaySinh: '',
        DiaChi: '',
        GioiTinh: '',
        DienThoai: '',
        Email: '',
        MaSoBaoHiem: '',
        TrinhDo: '',
        TonGiao: '',
        ChungChiChuyenNghanh: '',
        ChungChiAnhVan: '',
        imgEmployPath: '',
        CVPath: '',
        ScoreTablePath: '',
        CertificatePath: '',
        HouseholdPath: '',
        DiplomaPath: '',
        HealthCertificationPath: '',
        PhongBan: '',
        ChucVu: '',
        maPhongBan: '',
        maChucVu: '',
        maChuyenNghanh: '',
        ChuyenNghanh: '',
        TuNgay: '',
        DenNgay: '',
        MaNhanVien: ''
    };

var clearEmployee = function(){
        $scope.employee = {
        Ho: '',
        Ten: '',
        NgaySinh: '',
        DiaChi: '',
        GioiTinh: '',
        DienThoai: '',
        Email: '',
        MaSoBaoHiem: '',
        TrinhDo: '',
        TonGiao: '',
        ChungChiChuyenNghanh: '',
        ChungChiAnhVan: '',
        imgEmployPath: '',
        CVPath: '',
        ScoreTablePath: '',
        CertificatePath: '',
        HouseholdPath: '',
        DiplomaPath: '',
        HealthCertificationPath: '',
        PhongBan: '',
        ChucVu: '',
        maPhongBan: '',
        maChucVu: '',
        maChuyenNghanh: '',
        ChuyenNghanh: '',
        TuNgay: '',
        DenNgay: '',
        MaNhanVien: ''
    };
    $scope.CVs[0].name = '';
    $scope.ScoreTables[0].name = '';
    $scope.Certificates[0].name = '';
    $scope.Households[0].name = '';
    $scope.Diplomas[0].name = '';
    $scope.HealthCertifications[0].name = '';
};
    // Lưu
    $scope.Save = function(){     
        //console.log($scope.employee);
        if(!checkDepartment()){
            alert('Vui lòng chọn Phò<NAME>');
        } else if(!checkRole()){
            alert('VUi lòng chọn Chức Vụ');
        } else if(!checkMajor()){
            alert('Vui lòng chọn Chuyên Nghành');
        } else if(!checkGender()){
            alert('Vui lòng chọn Giới Tính');
        } else{
            QLNS.employee.POST($scope.employee).then(function(res){
                alert(res.data);
                clearEmployee();
                refesh();
            });
        }
    };

    $scope.selectDepartment = function(mpb, pb){
        $scope.employee.maPhongBan = mpb;
        $scope.employee.PhongBan = pb;
        console.log(pb);
    };

    $scope.selectRole = function(mcv, cv){
        $scope.employee.maChucVu = mcv;
        $scope.employee.ChucVu = cv;
        console.log(cv);
    };

    $scope.selectMajoring = function(mcn, cn){
        $scope.employee.maChuyenNghanh = mcn;
        $scope.employee.ChuyenNghanh = cn;
        console.log(cn);
    };

    $scope.selectGender = function(genderName){
        if(genderName === 'Nam'){
            $scope.employee.GioiTinh = 1;
            $scope.gender = genderName;
        } else if(genderName === 'Nữ'){
            $scope.employee.GioiTinh = 0;
            $scope.gender = genderName;
        }
    };

    //Refesh Add Employee page
    var refesh = function(){
        $scope.employee.PhongBan = 'Chọn';
        $scope.employee.ChucVu = 'Chọn';
        $scope.employee.ChuyenNghanh = 'Chọn';
        $scope.gender = 'Chọn';
        QLNS.department.GETNAME().then(function(res){
            //console.log(res.data);
            $scope.departments = res.data;
        });
        QLNS.role.GETNAME().then(function(res){
            //console.log(res.data);
            $scope.roles = res.data;
        });
        QLNS.majoring.GET().then(function(res){
            //console.log(res.data);
            $scope.majoring = res.data;
        });
    };
    refesh();

    // Check Phòng Ban
    var checkDepartment = function(){
        return !($scope.employee.PhongBan === 'Chọn' || $scope.employee.PhongBan === '');
    };

    // check Chức Vụ
    var checkRole = function(){
        return !($scope.employee.ChucVu === 'Chọn' || $scope.employee.ChucVu === '');
    };

    // check Chuyên Nghành
    var checkMajor = function(){
        return !($scope.employee.ChuyenNghanh === 'Chọn' || $scope.employee.ChuyenNghanh === '');
    };

    // check Giới Tính
    var checkGender = function(){
        return !($scope.gender === 'Chọn' || $scope.gender === '');
    };

    // Image Employee
    $scope.$watch('imgEmploys', function () {
        //console.log($scope.imgEmploys);  
        $scope.uploadImage($scope.imgEmploys);
    });
    $scope.$watch('imgEmploy', function () {
        if ($scope.imgEmploy != null) {
            //console.log($scope.files);
            $scope.imgEmploys = [$scope.imgEmploy]; 
        }
    });
    $scope.logimg = '';
{'fraction_non_alphanumeric': 0.16840329463133868, 'fraction_numerical': 0.001587774139128709, 'mean_word_length': 1.7550574084199015, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4653478', 'n_tokens_mistral': 3474, 'n_tokens_neox': 3335, 'n_words': 493}