Compare commits
10 Commits
k-kobayash
...
25986b455e
| Author | SHA1 | Date | |
|---|---|---|---|
| 25986b455e | |||
| c7a33c997c | |||
| 3818da7b4e | |||
| f37dd792a0 | |||
| 109b8125d6 | |||
| 626c4d6721 | |||
| e43958a1fb | |||
| 57a76ae044 | |||
| 4880a4285e | |||
| 03b1b7d982 |
@@ -49,7 +49,7 @@ public class GlobalExceptionHandler {
|
|||||||
|
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||||
|
|
||||||
System.out.println("session invalidated");
|
System.out.println("session invalidated method not supported exception");
|
||||||
session.invalidate();
|
session.invalidate();
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ public interface AllocationService {
|
|||||||
|
|
||||||
public List<AllocationModel> findAll();
|
public List<AllocationModel> findAll();
|
||||||
|
|
||||||
|
public List<AllocationModel> save(List<AllocationModel> allocationModelList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.example.demo.app.domain.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.example.demo.app.domain.model.CourseModel;
|
import com.example.demo.app.domain.model.CourseModel;
|
||||||
import com.example.demo.app.presentation.form.AllocationFormList;
|
|
||||||
|
|
||||||
public interface CourseService {
|
public interface CourseService {
|
||||||
|
|
||||||
@@ -13,14 +12,12 @@ public interface CourseService {
|
|||||||
|
|
||||||
public Long findByName(String courName);
|
public Long findByName(String courName);
|
||||||
|
|
||||||
public CourseModel save(CourseModel courseModel, Long userId, AllocationFormList allocationFormList);
|
public CourseModel save(CourseModel courseModel, Long userId);
|
||||||
|
|
||||||
public List<CourseModel> findAllByUserId(Long userId);
|
public List<CourseModel> findAllByUserId(Long userId);
|
||||||
|
|
||||||
public List<CourseModel> findAllByNull();
|
public List<CourseModel> findAllByNull();
|
||||||
|
|
||||||
public String deleteCourse(Long courseId, Long userId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.example.demo.app.domain.service.impl;
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -25,5 +26,26 @@ public class AllocationServiceImpl implements AllocationService {
|
|||||||
return AllocationEntity.createAllocationModelList(allocationRepository.findAll());
|
return AllocationEntity.createAllocationModelList(allocationRepository.findAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<AllocationModel> save(List<AllocationModel> allocationModelList) {
|
||||||
|
|
||||||
|
List<AllocationEntity> allocationEntityList = new ArrayList<>();
|
||||||
|
|
||||||
|
allocationModelList.forEach(allocationModel -> {
|
||||||
|
allocationEntityList.add(
|
||||||
|
AllocationModel.convertTo(
|
||||||
|
categoryRepository.findById(allocationModel.getCategoryId()).get(),
|
||||||
|
courseRepository.findById(allocationModel.getCourseId()).get(),
|
||||||
|
allocationModel.getAllocationRatio()));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
List<AllocationModel> result = new ArrayList<>();
|
||||||
|
for (AllocationEntity allocationEntity : allocationEntityList) {
|
||||||
|
result.add(AllocationModel.convertFrom(allocationRepository.save(allocationEntity)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,19 +7,14 @@ import jakarta.transaction.Transactional;
|
|||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.example.demo.app.domain.model.AllocationModel;
|
|
||||||
import com.example.demo.app.domain.model.CourseModel;
|
import com.example.demo.app.domain.model.CourseModel;
|
||||||
import com.example.demo.app.domain.service.CourseService;
|
import com.example.demo.app.domain.service.CourseService;
|
||||||
import com.example.demo.app.infra.entity.AllocationEntity;
|
|
||||||
import com.example.demo.app.infra.entity.CourseEntity;
|
import com.example.demo.app.infra.entity.CourseEntity;
|
||||||
import com.example.demo.app.infra.entity.CourseOwnerEntity;
|
import com.example.demo.app.infra.entity.CourseOwnerEntity;
|
||||||
import com.example.demo.app.infra.entity.UserEntity;
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
import com.example.demo.app.infra.repository.AllocationRepository;
|
|
||||||
import com.example.demo.app.infra.repository.CategoryRepository;
|
|
||||||
import com.example.demo.app.infra.repository.CourseOwnerRepository;
|
import com.example.demo.app.infra.repository.CourseOwnerRepository;
|
||||||
import com.example.demo.app.infra.repository.CourseRepository;
|
import com.example.demo.app.infra.repository.CourseRepository;
|
||||||
import com.example.demo.app.infra.repository.UserRepository;
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
import com.example.demo.app.presentation.form.AllocationFormList;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@@ -27,121 +22,53 @@ import lombok.RequiredArgsConstructor;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CourseServiceImpl implements CourseService {
|
public class CourseServiceImpl implements CourseService {
|
||||||
|
|
||||||
private final AllocationRepository allocationRepository;
|
|
||||||
|
|
||||||
private final CourseRepository courseRepository;
|
private final CourseRepository courseRepository;
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final CourseOwnerRepository courseOwnerRepository;
|
private final CourseOwnerRepository courseOwnerRepository;
|
||||||
private final CategoryRepository categoryRepository;
|
|
||||||
|
public List<CourseModel> findAll(){
|
||||||
public List<CourseModel> findAll() {
|
|
||||||
|
|
||||||
return CourseEntity.createCourseModelList(courseRepository.findAll());
|
return CourseEntity.createCourseModelList(courseRepository.findAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CourseModel> findAllByUserId(Long userId) {
|
public List<CourseModel> findAllByUserId(Long userId) {
|
||||||
|
|
||||||
return CourseModel.convertFrom(courseRepository.findAllByUserId(userId));
|
return CourseModel.convertFrom(courseRepository.findAllByUserId(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CourseModel> findAllByNull() {
|
public List<CourseModel> findAllByNull() {
|
||||||
return CourseModel.convertFrom(courseRepository.findAllByNull());
|
return CourseModel.convertFrom(courseRepository.findAllByNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CourseModel findById(Long courseId) {
|
public CourseModel findById(Long courseId) {
|
||||||
return CourseModel.convertFrom(courseRepository.findByCourseId(courseId));
|
return CourseModel.convertFrom(courseRepository.findByCourseId(courseId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long findByName(String courseName) {
|
public Long findByName(String courseName) {
|
||||||
return courseRepository.findByCourseName(courseName).getCourseId();
|
return courseRepository.findByCourseName(courseName).getCourseId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public CourseModel save(CourseModel courseModel, Long userId, AllocationFormList allocationFormList) {
|
public CourseModel save(CourseModel courseModel, Long userId) {
|
||||||
|
|
||||||
List<UserEntity> userEntityList = new ArrayList<>();
|
List<UserEntity> userEntityList = new ArrayList<>();
|
||||||
userEntityList.add(userRepository.findById(userId).get());
|
userEntityList.add(userRepository.findById(userId).get());
|
||||||
CourseEntity result = courseRepository.save(CourseModel.convertTo(courseModel));
|
CourseEntity result = courseRepository.save( CourseModel.convertTo(courseModel));
|
||||||
|
|
||||||
List<AllocationModel> allocationModelList = new ArrayList<>();
|
|
||||||
|
|
||||||
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId4(),
|
|
||||||
result.getCourseId(),
|
|
||||||
allocationFormList.getAllocationRatio4()));
|
|
||||||
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId5(),
|
|
||||||
result.getCourseId(),
|
|
||||||
allocationFormList.getAllocationRatio5()));
|
|
||||||
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId6(),
|
|
||||||
result.getCourseId(),
|
|
||||||
allocationFormList.getAllocationRatio6()));
|
|
||||||
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId7(),
|
|
||||||
result.getCourseId(),
|
|
||||||
allocationFormList.getAllocationRatio7()));
|
|
||||||
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId8(),
|
|
||||||
result.getCourseId(),
|
|
||||||
allocationFormList.getAllocationRatio8()));
|
|
||||||
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId9(),
|
|
||||||
result.getCourseId(),
|
|
||||||
allocationFormList.getAllocationRatio9()));
|
|
||||||
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId10(),
|
|
||||||
result.getCourseId(),
|
|
||||||
allocationFormList.getAllocationRatio10()));
|
|
||||||
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId11(),
|
|
||||||
result.getCourseId(),
|
|
||||||
allocationFormList.getAllocationRatio11()));
|
|
||||||
|
|
||||||
allocationModelList.stream().forEach(allocation -> {
|
|
||||||
System.out.println(allocation.getCourseId());
|
|
||||||
});
|
|
||||||
|
|
||||||
UserEntity user = userRepository.findById(userId).orElse(null);
|
UserEntity user = userRepository.findById(userId).orElse(null);
|
||||||
|
|
||||||
user.setCourseEntity(result);
|
user.setCourseEntity(result);
|
||||||
|
|
||||||
UserEntity userResult = userRepository.save(user);
|
UserEntity userResult = userRepository.save(user);
|
||||||
|
|
||||||
CourseOwnerEntity courseOwnerEntity = new CourseOwnerEntity();
|
CourseOwnerEntity courseOwnerEntity = new CourseOwnerEntity();
|
||||||
courseOwnerEntity.setUserEntity(userResult);
|
courseOwnerEntity.setUserEntity(userResult);
|
||||||
courseOwnerEntity.setCourseEntity(result);
|
courseOwnerEntity.setCourseEntity(result);
|
||||||
|
|
||||||
courseOwnerRepository.save(courseOwnerEntity);
|
courseOwnerRepository.save(courseOwnerEntity);
|
||||||
|
|
||||||
List<AllocationEntity> allocationEntityList = new ArrayList<>();
|
|
||||||
|
|
||||||
allocationModelList.forEach(allocationModel -> {
|
|
||||||
allocationEntityList.add(
|
|
||||||
AllocationModel.convertTo(
|
|
||||||
categoryRepository.findById(allocationModel.getCategoryId()).get(),
|
|
||||||
courseRepository.findById(allocationModel.getCourseId()).get(),
|
|
||||||
allocationModel.getAllocationRatio()));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
List<AllocationModel> resultList = new ArrayList<>();
|
|
||||||
for (AllocationEntity allocationEntity : allocationEntityList) {
|
|
||||||
resultList.add(AllocationModel.convertFrom(allocationRepository.save(allocationEntity)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return CourseModel.convertFrom(result);
|
return CourseModel.convertFrom(result);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public String deleteCourse(Long courseId, Long userId) {
|
|
||||||
|
|
||||||
UserEntity userEntity = userRepository.findById(userId).orElse(null);
|
|
||||||
System.out.println("***********************ここでエラー1");
|
|
||||||
if (userEntity.getCourseEntity().getCourseId() == courseId) {
|
|
||||||
return "selected";
|
|
||||||
}
|
|
||||||
System.out.println("***********************ここでエラー2");
|
|
||||||
allocationRepository.deleteByCourseId(courseId);
|
|
||||||
System.out.println("***********************ここでエラー3");
|
|
||||||
courseOwnerRepository.deleteByCourseId(courseId);
|
|
||||||
System.out.println("***********************ここでエラー4");
|
|
||||||
courseRepository.deleteById(courseId);
|
|
||||||
System.out.println("***********************ここでエラー5");
|
|
||||||
return "ok";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.example.demo.app.infra.repository;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
import com.example.demo.app.domain.model.CourseInfoModel;
|
import com.example.demo.app.domain.model.CourseInfoModel;
|
||||||
@@ -29,9 +28,5 @@ public interface AllocationRepository extends JpaRepository<AllocationEntity, Al
|
|||||||
+ " ORDER BY a.courseEntity.courseId ASC, "
|
+ " ORDER BY a.courseEntity.courseId ASC, "
|
||||||
+ " a.categoryEntity.categoryId ASC ")
|
+ " a.categoryEntity.categoryId ASC ")
|
||||||
List<CourseInfoModel> findAllJoinedAllocation();
|
List<CourseInfoModel> findAllJoinedAllocation();
|
||||||
|
|
||||||
@Modifying
|
|
||||||
@Query("delete from AllocationEntity a where a.courseEntity.courseId = :courseId")
|
|
||||||
void deleteByCourseId(Long courseId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
package com.example.demo.app.infra.repository;
|
package com.example.demo.app.infra.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
|
|
||||||
import com.example.demo.app.infra.entity.CourseOwnerEntity;
|
import com.example.demo.app.infra.entity.CourseOwnerEntity;
|
||||||
|
|
||||||
public interface CourseOwnerRepository extends JpaRepository<CourseOwnerEntity, Long>{
|
public interface CourseOwnerRepository extends JpaRepository<CourseOwnerEntity, Long>{
|
||||||
|
|
||||||
@Modifying
|
|
||||||
@Query("delete from CourseOwnerEntity c where c.courseEntity.courseId = :courseId")
|
|
||||||
public void deleteByCourseId(Long courseId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import com.example.demo.aop.aspect.SessionCheck;
|
import com.example.demo.aop.aspect.SessionCheck;
|
||||||
|
import com.example.demo.app.domain.model.AllocationModel;
|
||||||
import com.example.demo.app.domain.model.CourseModel;
|
import com.example.demo.app.domain.model.CourseModel;
|
||||||
import com.example.demo.app.domain.model.LoginModel;
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
import com.example.demo.app.domain.service.AllocationService;
|
import com.example.demo.app.domain.service.AllocationService;
|
||||||
@@ -110,44 +111,48 @@ public class CourseController {
|
|||||||
|
|
||||||
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
|
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
|
||||||
|
|
||||||
model.addAttribute("courseForm", courseForm);
|
CourseForm form = CourseForm
|
||||||
|
.convertFrom(courseService.save(CourseForm.convertTo(courseForm), loginUser.getUserId()));
|
||||||
|
|
||||||
|
session.setAttribute(PageReturnAttributeKeyword.COURSE_ID, form.getCourseId());
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.COURSE_CREATE_RATIO_HTML;
|
return TransitionTargetPageNameKeyword.COURSE_CREATE_RATIO_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@PostMapping(TransitionTargetPageNameKeyword.COURSE_CREATE)
|
@PostMapping(TransitionTargetPageNameKeyword.COURSE_CREATE)
|
||||||
public String createCoursePost(@ModelAttribute CourseForm courseForm,
|
public String createCoursePost(@ModelAttribute AllocationFormList allocationFormList, HttpSession session) {
|
||||||
@ModelAttribute AllocationFormList allocationFormList, HttpSession session) {
|
|
||||||
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
|
|
||||||
|
|
||||||
courseService.save(CourseForm.convertTo(courseForm), loginUser.getUserId(), allocationFormList);
|
List<AllocationModel> allocationModelList = new ArrayList<>();
|
||||||
|
|
||||||
|
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId4(),
|
||||||
|
(Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID),
|
||||||
|
allocationFormList.getAllocationRatio4()));
|
||||||
|
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId5(),
|
||||||
|
(Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID),
|
||||||
|
allocationFormList.getAllocationRatio5()));
|
||||||
|
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId6(),
|
||||||
|
(Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID),
|
||||||
|
allocationFormList.getAllocationRatio6()));
|
||||||
|
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId7(),
|
||||||
|
(Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID),
|
||||||
|
allocationFormList.getAllocationRatio7()));
|
||||||
|
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId8(),
|
||||||
|
(Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID),
|
||||||
|
allocationFormList.getAllocationRatio8()));
|
||||||
|
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId9(),
|
||||||
|
(Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID),
|
||||||
|
allocationFormList.getAllocationRatio9()));
|
||||||
|
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId10(),
|
||||||
|
(Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID),
|
||||||
|
allocationFormList.getAllocationRatio10()));
|
||||||
|
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId11(),
|
||||||
|
(Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID),
|
||||||
|
allocationFormList.getAllocationRatio11()));
|
||||||
|
|
||||||
|
allocationService.save(allocationModelList);
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
|
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionCheck
|
|
||||||
@PostMapping("/course/delete")
|
|
||||||
public String createCoursePost(@RequestParam Long courseId, HttpSession session, Model model) {
|
|
||||||
|
|
||||||
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
|
|
||||||
|
|
||||||
System.out.println("**********************cousrId: " + courseId);
|
|
||||||
String condition = courseService.deleteCourse(courseId, loginUser.getUserId());
|
|
||||||
|
|
||||||
if (condition.equals("selected")) {
|
|
||||||
|
|
||||||
model.addAttribute("message", "適用中のコースは選べません");
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
|
|
||||||
|
|
||||||
} else if (condition.equals("ok")) {
|
|
||||||
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
|
|
||||||
}
|
|
||||||
model.addAttribute("message", "エラーが発生しました");
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -372,29 +372,29 @@ public class TransactionController {
|
|||||||
@RequestParam(required = false, defaultValue = "0") String months) {
|
@RequestParam(required = false, defaultValue = "0") String months) {
|
||||||
|
|
||||||
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
|
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
|
||||||
|
System.out.println("******************************************::1");
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
|
System.out.println("******************************************::2");
|
||||||
int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years);
|
int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years);
|
||||||
|
System.out.println("******************************************::3");
|
||||||
int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months);
|
int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months);
|
||||||
|
System.out.println("******************************************::4");
|
||||||
YearMonth yearMonth = YearMonth.of(year, month);
|
YearMonth yearMonth = YearMonth.of(year, month);
|
||||||
|
System.out.println("******************************************::5");
|
||||||
int lastDay = yearMonth.lengthOfMonth();
|
int lastDay = yearMonth.lengthOfMonth();
|
||||||
|
System.out.println("******************************************::6");
|
||||||
int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7;
|
int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7;
|
||||||
|
System.out.println("******************************************::7");
|
||||||
YearMonth previousYearMonth = yearMonth.minusMonths(1);
|
YearMonth previousYearMonth = yearMonth.minusMonths(1);
|
||||||
|
System.out.println("******************************************::8");
|
||||||
int previousYear = previousYearMonth.getYear();
|
int previousYear = previousYearMonth.getYear();
|
||||||
int previousMonth = previousYearMonth.getMonthValue();
|
int previousMonth = previousYearMonth.getMonthValue();
|
||||||
|
System.out.println("******************************************::9");
|
||||||
YearMonth nextYearMonth = yearMonth.plusMonths(1);
|
YearMonth nextYearMonth = yearMonth.plusMonths(1);
|
||||||
|
System.out.println("******************************************::10");
|
||||||
int nextYear = nextYearMonth.getYear();
|
int nextYear = nextYearMonth.getYear();
|
||||||
int nextMonth = nextYearMonth.getMonthValue();
|
int nextMonth = nextYearMonth.getMonthValue();
|
||||||
|
System.out.println("******************************************::11");
|
||||||
model.addAttribute(PageReturnAttributeKeyword.YEAR, year);
|
model.addAttribute(PageReturnAttributeKeyword.YEAR, year);
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MONTH, month);
|
model.addAttribute(PageReturnAttributeKeyword.MONTH, month);
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DAY, today.getDayOfMonth());
|
model.addAttribute(PageReturnAttributeKeyword.DAY, today.getDayOfMonth());
|
||||||
@@ -407,34 +407,34 @@ public class TransactionController {
|
|||||||
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.NEXT_YEAR, nextYear);
|
model.addAttribute(PageReturnAttributeKeyword.NEXT_YEAR, nextYear);
|
||||||
model.addAttribute(PageReturnAttributeKeyword.NEXT_MONTH, nextMonth);
|
model.addAttribute(PageReturnAttributeKeyword.NEXT_MONTH, nextMonth);
|
||||||
|
System.out.println("******************************************::12");
|
||||||
LocalDate startDate = yearMonth.atDay(1);
|
LocalDate startDate = yearMonth.atDay(1);
|
||||||
LocalDate endDate = yearMonth.atEndOfMonth();
|
LocalDate endDate = yearMonth.atEndOfMonth();
|
||||||
|
System.out.println("******************************************::13");
|
||||||
List<Income> incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId());
|
List<Income> incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId());
|
||||||
|
System.out.println("******************************************::14");
|
||||||
List<Expense> expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId());
|
List<Expense> expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId());
|
||||||
|
System.out.println("******************************************::15");
|
||||||
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
|
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
|
||||||
model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
|
model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
|
||||||
|
System.out.println("******************************************::16");
|
||||||
int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId());
|
int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId());
|
||||||
|
|
||||||
int totalExpense = transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId());
|
int totalExpense = transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId());
|
||||||
|
System.out.println("******************************************::17");
|
||||||
model.addAttribute(PageReturnAttributeKeyword.TOTAL_INCOME, totalIncome);
|
model.addAttribute(PageReturnAttributeKeyword.TOTAL_INCOME, totalIncome);
|
||||||
model.addAttribute(PageReturnAttributeKeyword.TOTAL_EXPENSE, totalExpense);
|
model.addAttribute(PageReturnAttributeKeyword.TOTAL_EXPENSE, totalExpense);
|
||||||
|
System.out.println("******************************************::18");
|
||||||
List<GoalForm> goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId()));
|
List<GoalForm> goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId()));
|
||||||
|
System.out.println("******************************************::19");
|
||||||
UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId()));
|
UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId()));
|
||||||
|
System.out.println("******************************************::20");
|
||||||
List<GoalForm> resultList = goalForm.stream().filter(goal -> goal.getGoalComplete() == 0 && goal.getDeadline().isAfter(today) )
|
List<GoalForm> resultList = goalForm.stream().filter(goal -> goal.getGoalComplete() == 0)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
System.out.println("******************************************::21");
|
||||||
if (!resultList.isEmpty()) {
|
if (!resultList.isEmpty()) {
|
||||||
GoalForm result = resultList.getFirst();
|
GoalForm result = resultList.getFirst();
|
||||||
|
System.out.println("******************************************::22");
|
||||||
model.addAttribute(PageReturnAttributeKeyword.ACHIEVEMENT_RATE, result.getAchievementRate());
|
model.addAttribute(PageReturnAttributeKeyword.ACHIEVEMENT_RATE, result.getAchievementRate());
|
||||||
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.CURRENT_AMOUNT, result.getCurrentAmount());
|
model.addAttribute(PageReturnAttributeKeyword.CURRENT_AMOUNT, result.getCurrentAmount());
|
||||||
|
|||||||
@@ -24,66 +24,60 @@
|
|||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="allocationRatio4">固定費</label>
|
<label class="form-label" for="allocationRatio4">固定費</label>
|
||||||
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
|
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()" id="allocationRatio4" th:field="*{allocationRatio4}" required>
|
||||||
id="allocationRatio4" th:field="*{allocationRatio4}" required>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="allocationRatio5">食費</label>
|
<label class="form-label" for="allocationRatio5">食費</label>
|
||||||
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
|
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()" id="allocationRatio5" th:field="*{allocationRatio5}" required>
|
||||||
id="allocationRatio5" th:field="*{allocationRatio5}" required>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="allocationRatio6">交通費</label>
|
<label class="form-label" for="allocationRatio6">交通費</label>
|
||||||
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
|
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()" id="allocationRatio6" th:field="*{allocationRatio6}" required>
|
||||||
id="allocationRatio6" th:field="*{allocationRatio6}" required>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="allocationRatio7">日用品費</label>
|
<label class="form-label" for="allocationRatio7">日用品費</label>
|
||||||
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
|
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()" id="allocationRatio7" th:field="*{allocationRatio7}" required>
|
||||||
id="allocationRatio7" th:field="*{allocationRatio7}" required>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="allocationRatio8">被服/美容費</label>
|
<label class="form-label" for="allocationRatio8">被服/美容費</label>
|
||||||
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
|
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()" id="allocationRatio8" th:field="*{allocationRatio8}" required>
|
||||||
id="allocationRatio8" th:field="*{allocationRatio8}" required>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="allocationRatio9">医療費</label>
|
<label class="form-label" for="allocationRatio9">医療費</label>
|
||||||
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
|
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()" id="allocationRatio9" th:field="*{allocationRatio9}" required>
|
||||||
id="allocationRatio9" th:field="*{allocationRatio9}" required>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="allocationRatio10">趣味/娯楽費</label>
|
<label class="form-label" for="allocationRatio10">趣味/娯楽費</label>
|
||||||
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
|
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()" id="allocationRatio10"
|
||||||
id="allocationRatio10" th:field="*{allocationRatio10}" required>
|
th:field="*{allocationRatio10}" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="allocationRatio11">その他</label>
|
<label class="form-label" for="allocationRatio11">その他</label>
|
||||||
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()"
|
<input class="form-control" type="number" min="0" max="100" onchange="inputChange()" id="allocationRatio11"
|
||||||
id="allocationRatio11" th:field="*{allocationRatio11}" required>
|
th:field="*{allocationRatio11}" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="allocationRatioTotal">合計(%)</label>
|
<label class="form-label" for="allocationRatioTotal">合計(%)</label>
|
||||||
<input class="form-control" type="number" value="0" id="allocationRatioTotal" readonly>
|
<input class="form-control" type="number" value="0" id="allocationRatioTotal" readonly>
|
||||||
@@ -94,40 +88,32 @@
|
|||||||
<button type="submit" class="btn btn-primary" id="submit" disabled="true">登録</button>
|
<button type="submit" class="btn btn-primary" id="submit" disabled="true">登録</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
<span th:object="${courseForm}">
|
|
||||||
|
|
||||||
<input type="hidden" id="courseName" th:field="*{courseName}" required>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<input type="hidden" id="description" th:field="*{description}">
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div th:replace="~{footer :: footer}"></div>
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function inputChange() {
|
function inputChange(){
|
||||||
let total = 0;
|
let total=0;
|
||||||
|
|
||||||
for (let i = 4; i <= 11; i++) {
|
for(let i=4; i<=11; i++){
|
||||||
total += Number(document.getElementById(`allocationRatio${i}`).value || 0);
|
total += Number(document.getElementById(`allocationRatio${i}`).value || 0);
|
||||||
if (total == 100) {
|
if(total == 100){
|
||||||
document.getElementById('submit').disabled = false;
|
document.getElementById('submit').disabled = false;
|
||||||
} else {
|
}else{
|
||||||
document.getElementById('submit').disabled = true;
|
document.getElementById('submit').disabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("allocationRatioTotal").value = total;
|
document.getElementById("allocationRatioTotal").value = total;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="transactionType">収入・支出</label>
|
<label class="form-label" for="transactionType">収入・支出</label>
|
||||||
|
|
||||||
<select class="form-select" id="transactionType" required>
|
<select class="form-select" id="transactionType">
|
||||||
|
|
||||||
<option value="">選択してください</option>
|
<option value="">選択してください</option>
|
||||||
<option value="0">支出</option>
|
<option value="0">支出</option>
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="categoryId">カテゴリ</label>
|
<label class="form-label" for="categoryId">カテゴリ</label>
|
||||||
|
|
||||||
<select class="form-select" id="categoryId" th:field="*{categoryId}" required>
|
<select class="form-select" id="categoryId" th:field="*{categoryId}">
|
||||||
<option value="">選択してください</option>
|
<option value="">選択してください</option>
|
||||||
|
|
||||||
<option class="expenseListClass" th:each="category : ${expenseList}"
|
<option class="expenseListClass" th:each="category : ${expenseList}"
|
||||||
|
|||||||
@@ -23,13 +23,6 @@
|
|||||||
</th:block>
|
</th:block>
|
||||||
|
|
||||||
<form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" method="post">
|
<form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" method="post">
|
||||||
<th:block th:if="${mode == 'change'}">
|
|
||||||
<form th:action="@{/course/create}" method="get">
|
|
||||||
<button type="submit">新規登録</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</th:block>
|
|
||||||
<form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" id="totalForm" method="post">
|
|
||||||
<button type="submit" class="btn btn-primary w-100">確定</button>
|
<button type="submit" class="btn btn-primary w-100">確定</button>
|
||||||
|
|
||||||
<div class="accordion" id="accordionExample">
|
<div class="accordion" id="accordionExample">
|
||||||
@@ -42,8 +35,6 @@
|
|||||||
aria-controls="'collapse' + ${course.courseId}">
|
aria-controls="'collapse' + ${course.courseId}">
|
||||||
<span th:text="${course.courseName}"></span>
|
<span th:text="${course.courseName}"></span>
|
||||||
</button>
|
</button>
|
||||||
<p style="width: 120px;"><button type="button" class="btn btn-danger w-100"
|
|
||||||
th:attr="data-course-id=${course.courseId}" onclick="deleteCourse(this)">削除</button></p>
|
|
||||||
</h2>
|
</h2>
|
||||||
<div th:id="'collapse' + ${course.courseId}" class="accordion-collapse collapse"
|
<div th:id="'collapse' + ${course.courseId}" class="accordion-collapse collapse"
|
||||||
data-bs-parent="#accordionExample" style="padding-bottom: 120px;">
|
data-bs-parent="#accordionExample" style="padding-bottom: 120px;">
|
||||||
@@ -71,43 +62,6 @@
|
|||||||
<div th:replace="~{footer :: footer}"></div>
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
</th:block>
|
</th:block>
|
||||||
|
|
||||||
<script th:inline="javascript">
|
|
||||||
|
|
||||||
const message = /*[[${message}]]*/ null;
|
|
||||||
|
|
||||||
if (message != null) {
|
|
||||||
alert(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteCourse(button) {
|
|
||||||
|
|
||||||
const courseId = button.dataset.courseId;
|
|
||||||
|
|
||||||
const totalForm = document.getElementById("totalForm");
|
|
||||||
|
|
||||||
const input = document.createElement("input");
|
|
||||||
|
|
||||||
const radioButtons = totalForm.querySelectorAll('input[name="courseId"]');
|
|
||||||
radioButtons.forEach(radio => {
|
|
||||||
radio.disabled = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
input.type = "hidden";
|
|
||||||
input.name = "courseId";
|
|
||||||
input.value = courseId;
|
|
||||||
|
|
||||||
totalForm.appendChild(input);
|
|
||||||
|
|
||||||
totalForm.action = "/course/delete";
|
|
||||||
totalForm.method = "post";
|
|
||||||
courseId.value = courseId;
|
|
||||||
|
|
||||||
totalForm.submit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -113,66 +113,58 @@
|
|||||||
|
|
||||||
<div th:replace="~{footer :: footer}"></div>
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
|
||||||
<script th:inline="javascript">
|
<script inline="javascript">
|
||||||
const transactionType = document.getElementById("transactionType");
|
const transactionType = document.getElementById("transactionType");
|
||||||
const categoryId = document.getElementById("categoryId");
|
const categoryId = document.getElementById("categoryId");
|
||||||
|
|
||||||
const expenseList = document.getElementsByClassName("expenseListClass");
|
const expenseList = document.getElementsByClassName("expenseListClass");
|
||||||
const incomeList = document.getElementsByClassName("incomeListClass");
|
const incomeList = document.getElementsByClassName("incomeListClass");
|
||||||
|
|
||||||
const tType = '[[${session.tType}]]';
|
const tType = '[[${session.tType}]]';
|
||||||
|
|
||||||
function toggleCategory() {
|
if (tType == "0") {
|
||||||
|
transactionType.value = 0;
|
||||||
|
} else if (tType == "1") {
|
||||||
|
transactionType.value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
transactionType.addEventListener("change", function () {
|
||||||
|
|
||||||
if (transactionType.value === "0") {
|
if (this.value === "0") {
|
||||||
|
|
||||||
for (let i = 0; i < expenseList.length; i++) {
|
for (let i = 0; i < expenseList.length; i++) {
|
||||||
expenseList[i].style.display = "";
|
expenseList[i].style.display = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < incomeList.length; i++) {
|
for (let i = 0; i < incomeList.length; i++) {
|
||||||
incomeList[i].style.display = "none";
|
incomeList[i].style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (transactionType.value === "1") {
|
} else if (this.value === "1") {
|
||||||
|
|
||||||
for (let i = 0; i < expenseList.length; i++) {
|
for (let i = 0; i < expenseList.length; i++) {
|
||||||
expenseList[i].style.display = "none";
|
expenseList[i].style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < incomeList.length; i++) {
|
for (let i = 0; i < incomeList.length; i++) {
|
||||||
incomeList[i].style.display = "";
|
incomeList[i].style.display = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for (let i = 0; i < expenseList.length; i++) {
|
for (let i = 0; i < expenseList.length; i++) {
|
||||||
expenseList[i].style.display = "none";
|
expenseList[i].style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < incomeList.length; i++) {
|
for (let i = 0; i < incomeList.length; i++) {
|
||||||
incomeList[i].style.display = "none";
|
incomeList[i].style.display = "none";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transactionType.addEventListener("change", function () {
|
categoryId.value = "";
|
||||||
|
});
|
||||||
toggleCategory();
|
</script>
|
||||||
|
|
||||||
categoryId.value = "";
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
if (tType == "0") {
|
|
||||||
transactionType.value = "0";
|
|
||||||
} else if (tType == "1") {
|
|
||||||
transactionType.value = "1";
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCategory();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -156,7 +156,7 @@
|
|||||||
<div th:replace="~{footer :: footer}">
|
<div th:replace="~{footer :: footer}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script th:inline="javascript">
|
<script inline="javascript">
|
||||||
const transactionType = document.getElementById("transactionType");
|
const transactionType = document.getElementById("transactionType");
|
||||||
const categoryId = document.getElementById("categoryId");
|
const categoryId = document.getElementById("categoryId");
|
||||||
|
|
||||||
@@ -165,29 +165,36 @@
|
|||||||
|
|
||||||
const tType = '[[${session.tType}]]';
|
const tType = '[[${session.tType}]]';
|
||||||
|
|
||||||
function toggleCategory() {
|
if (tType == "0") {
|
||||||
|
transactionType.value = 0;
|
||||||
|
} else if (tType == "1") {
|
||||||
|
transactionType.value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
transactionType.addEventListener("change", function () {
|
||||||
|
|
||||||
if (transactionType.value === "0") {
|
if (this.value === "0") {
|
||||||
|
|
||||||
for (let i = 0; i < expenseList.length; i++) {
|
for (let i = 0; i < expenseList.length; i++) {
|
||||||
expenseList[i].style.display = "";
|
expenseList[i].style.display = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < incomeList.length; i++) {
|
for (let i = 0; i < incomeList.length; i++) {
|
||||||
incomeList[i].style.display = "none";
|
incomeList[i].style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (transactionType.value === "1") {
|
} else if (this.value === "1") {
|
||||||
|
|
||||||
for (let i = 0; i < expenseList.length; i++) {
|
for (let i = 0; i < expenseList.length; i++) {
|
||||||
expenseList[i].style.display = "none";
|
expenseList[i].style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < incomeList.length; i++) {
|
for (let i = 0; i < incomeList.length; i++) {
|
||||||
incomeList[i].style.display = "";
|
incomeList[i].style.display = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for (let i = 0; i < expenseList.length; i++) {
|
for (let i = 0; i < expenseList.length; i++) {
|
||||||
expenseList[i].style.display = "none";
|
expenseList[i].style.display = "none";
|
||||||
@@ -197,24 +204,9 @@
|
|||||||
incomeList[i].style.display = "none";
|
incomeList[i].style.display = "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
transactionType.addEventListener("change", function () {
|
|
||||||
|
|
||||||
toggleCategory();
|
|
||||||
|
|
||||||
categoryId.value = "";
|
|
||||||
|
|
||||||
|
categoryId.value = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
if (tType == "0") {
|
|
||||||
transactionType.value = "0";
|
|
||||||
} else if (tType == "1") {
|
|
||||||
transactionType.value = "1";
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCategory();
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user