"use strict";
appCore.controller("EmailtemplateAddCtrl", ["$state", "$scope", "$http", "$timeout", "vServices", function ($state, $scope, $http, $timeout, vServices) {
    $scope.param = $state.params;
    $scope.createButton = {
        heading: "Add Email Template",
        text: "Add Email Template",
        icon: "fa-add"
    };
    $scope.$root.page.title = "Add Email Template";
    $scope.emailtemplates = [];
    $scope.save = () => {
			vServices.callApi("employee/add_email_template", "POST", $scope.emailtemplates).then((res) => {

            if (res) {
                toastr.success(res, "Success!", {timeOut: 5000});
                $scope.$root.updateMenu();
                $state.go("emailtemplateList", {}, {reload: true});
            }
        });
    };
    $scope.cancel = () =>{
        $state.go("emailtemplateList", {}, {reload: true});
    };
    const init = function () {
        if ($scope.param && typeof $scope.param.emailtemplateid !== "undefined") {
            vServices.callApi("employee/email_template/" + $scope.param.emailtemplateid, "GET", {}).then((obj) => {
                if (obj) {
                    $scope.emailtemplates = obj;
                }
            });
        }
    };
    init();
}]);
