/*

*/
angular.module("myApp").controller("timeSheetDetailController", function($scope, $http, $stateParams, $state) {
    console.log("Time Sheet Detail Controller");

    $scope.tsd = {
        "id": "",
        "checked": ""
    };

    $http({
        method : 'GET',
        url : "http://localhost:8080/eproject/timesheet/" + $stateParams.id
    }).then(function successCallback(response) {
        console.log(response);
        $scope.timeSheetDetail=response.data;
    }, function errorCallback(response) {
        console.log(response)
    });

    $scope.updateCheck = function updateCheck(id, check){
        $scope.tsd.id = id;
        $scope.tsd.checked = check;
        $http({
            headers: {"Content-Type": "application/json"},
            method : 'POST',
            url : "http://localhost:8080/eproject/timesheet/update/check",
            data: $scope.tsd
        }).then(function successCallback(response) {
            console.log(response);
            $state.reload();
        }, function errorCallback(response) {
            console.log(response);
            $state.reload();
        });
    }
});