Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #186 from hardingadonis/dev
Browse files Browse the repository at this point in the history
Release version 0.9.0
  • Loading branch information
hardingadonis authored Mar 12, 2024
2 parents 80ec584 + cb840a5 commit 6aca169
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 50 deletions.
2 changes: 1 addition & 1 deletion get_version.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

major_version=0
minor_version=8
minor_version=9
path_version=0

echo "$major_version.$minor_version.$path_version"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.hardingadonis</groupId>
<artifactId>saledock</artifactId>
<version>0.8.0</version>
<version>0.9.0</version>
<packaging>war</packaging>

<name>Sale Dock - v${project.version}</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String name = request.getParameter("name");
String code = request.getParameter("code");
String address = request.getParameter("address");
String email = request.getParameter("email");

try {
if (name.length() > 0 && code.length() > 0 && address.length() > 0 && email.length() > 0) {
if (name.length() > 0 && address.length() > 0 && email.length() > 0) {
Customer customer = new Customer();
customer.setName(name);
customer.setCode(code);
customer.setAddress(address);
customer.setEmail(email);
Singleton.customerDAO.save(customer);
Expand All @@ -48,9 +46,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
customer.setName(name);
customer.setAddress(address);
StringBuilder message = new StringBuilder("Tạo khách hàng không thành công: ");
if (e.getMessage().contains(code)) {
message.append("Không được trùng mã khách hàng.");
}
if (e.getMessage().contains(email)) {
message.append("Không được trùng email.");
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/io/hardingadonis/saledock/model/Customer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import jakarta.persistence.*;
import java.time.*;
import java.util.*;

import lombok.*;

@Entity(name = "Customer")
Expand Down Expand Up @@ -38,11 +40,18 @@ public class Customer {

@PrePersist
protected void onCreate() {
this.code = generateRandomCustomerCode();
this.createdAt = LocalDateTime.now(ZoneId.of("Asia/Ho_Chi_Minh"));
}

@PreUpdate
protected void onUpdate() {
this.updatedAt = LocalDateTime.now(ZoneId.of("Asia/Ho_Chi_Minh"));
}

private static String generateRandomCustomerCode() {
UUID uuid = UUID.randomUUID();

return uuid.toString().toUpperCase().replace("-", "").substring(0, 7);
}
}
5 changes: 0 additions & 5 deletions src/main/java/io/hardingadonis/saledock/model/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,4 @@ private static String generateRandomOrderCode() {

return uuid.toString().toUpperCase().replace("-", "").substring(0, 15);
}

public String getTotalToString() {
DecimalFormat decimalFormat = new DecimalFormat("#,###.#");
return decimalFormat.format(this.total);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/config.mysql.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
config.jdbc.url=database
config.jdbc.url=localhost
config.jdbc.database_name=saledock
config.jdbc.user=root
config.jdbc.password=
2 changes: 1 addition & 1 deletion src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<session-factory>
<!-- JDBC Database connection settings -->
<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://database:3306/saledock?createDatabaseIfNotExist=true</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/saledock?createDatabaseIfNotExist=true</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>

Expand Down
29 changes: 6 additions & 23 deletions src/main/webapp/view/jsp/management/customer/add-customer.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,15 @@
<div class="card-body">
<form action="./add-customer" method="post" id="form-add-customer">
<div class="row">
<div class="col">
<div class="mb-3 form-group">
<label class="form-label" for="name">
<strong>Tên khách hàng</strong>
</label>
<div class="mb-3 form-group">
<label class="form-label" for="name">
<strong>Tên khách hàng</strong>
</label>
<div class="mb-3 form-group">
<input class="form-control" type="text" id="name-customer" placeholder="Nhập tên khách hàng" name="name" value="<%= (error != null && customer != null) ? customer.getName() : ""%>">
<span class="form-message text-danger"></span>
</div>
</div>
</div>
<div class="col">
<div class="mb-3">
<label class="form-label" for="code">
<strong>Mã khách hàng</strong>
</label>
<div class="mb-3 form-group">
<input class="form-control" type="text" id="code-customer" placeholder="Mã khách hàng" name="code" >
<span class="form-message text-danger"></span>
</div>
<input class="form-control" type="text" id="name-customer" placeholder="Nhập tên khách hàng" name="name" value="<%= (error != null && customer != null) ? customer.getName() : ""%>">
<span class="form-message text-danger"></span>
</div>
</div>

</div>
<div class="mb-3">
<div class="mb-3">
Expand Down Expand Up @@ -122,11 +108,8 @@
formGroupSelector: '.form-group',
rules: [
Validator.isRequired('#name-customer', 'Vui lòng nhập tên khách hàng!'),
Validator.isRequired('#code-customer', 'Vui lòng nhập mã khách hàng!'),
Validator.isRequired('#address-customer', 'Vui lòng nhập địa chỉ khách hàng!'),
Validator.isRequired('#email-customer', 'Vui lòng nhập email khách hàng!')
]
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

<div class="col">
<div class="mb-3"><label class="form-label" for="email"><strong>Mã khách hàng</strong></label>
<input class="form-control" type="email" id="email" placeholder="${requestScope.cus.code}" name="email" readonly="">
<input class="form-control" type="email" id="email" placeholder="${requestScope.cus.code}" name="email" disabled>
</div>
</div>

Expand All @@ -61,7 +61,7 @@
</div>

<div class="mb-3"><label class="form-label" for="country"><strong>Email</strong></label>
<input class="form-control" type="text" id="country" placeholder="${requestScope.cus.email}" name="country" readonly="">
<input class="form-control" type="text" id="country" placeholder="${requestScope.cus.email}" name="country" disabled>
</div>

<button class="btn btn-primary btn-sm" type="button">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@
var quantity = parseInt($('#product-quantity').val());
var price = parseFloat($('#product-price').val().replace(/[^0-9.-]+/g, '')) * 1000;
var total = quantity * price;
if(isNaN(total)){
total = 0;
}
$('#product-total-price').val(formatCurrency(total));
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/webapp/view/jsp/management/order/update-order.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,35 @@
<div class="col">
<div class="mb-3">
<label class="form-label" for="username"><strong>Mã đơn hàng</strong></label>
<input class="form-control" type="text" id="username" value ="${requestScope.ord.code}" name="username" readonly="">
<input class="form-control" type="text" id="username" value ="${requestScope.ord.code}" name="username" disabled>
</div>
</div>

<div class="col">
<div class="mb-3">
<label class="form-label" for="email"><strong>Ngày tạo</strong></label>
<input class="form-control" type="email" id="createAt" value ="${requestScope.ord.createdAt}" name="email" readonly="">
<input class="form-control" type="email" id="createAt" value ="${requestScope.ord.createdAt}" name="email" disabled>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="mb-3">
<label class="form-label" for="username"><strong>Khách hàng</strong></label>
<input class="form-control" type="text" value ="${requestScope.ord.customer.name}" readonly="">
<input class="form-control" type="text" value ="${requestScope.ord.customer.name}" disabled>
</div>
</div>
<div class="col">
<div class="mb-3">
<label class="form-label" for="email"><strong>Nhân viên phụ trách</strong></label>
<input class="form-control" type="email" id="email-1" value = "${requestScope.ord.employee.fullName}" name="email" readonly="">
<input class="form-control" type="email" id="email-1" value = "${requestScope.ord.employee.fullName}" name="email" disabled>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="mb-3"><label class="form-label" for="username"><strong>Tổng tiền</strong></label>
<input class="form-control price" type ="text" value ="${requestScope.ord.total}" readonly="">
<input class="form-control price" type ="text" value ="${requestScope.ord.total}" disabled>
</div>
</div>

Expand All @@ -111,10 +111,10 @@
<c:choose>

<c:when test="${requestScope.ord.status == 'DONE'}">
<input class="form-control" type="email" id="email-2" value="Đã xong" name="email" readonly="">
<input class="form-control" type="email" id="email-2" value="Đã xong" name="email" disabled>
</c:when>
<c:when test="${requestScope.ord.status == 'CANCELLED'}">
<input class="form-control" type="email" id="email-2" value="Đã hủy" name="email" readonly="">
<input class="form-control" type="email" id="email-2" value="Đã hủy" name="email" disabled>
</c:when>
<c:otherwise>
<select class="form-control" name="status">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<label class="form-label" for="username">
<strong>Mã sản phẩm</strong>
</label>
<input class="form-control" type="text" id="username" value="${requestScope.pro.code}" name="username" readonly="" >
<input class="form-control" type="text" id="username" value="${requestScope.pro.code}" name="username" disabled >
</div>
</div>
<div class="col">
Expand All @@ -66,7 +66,7 @@
<label class="form-label" for="username">
<strong>Phân loại</strong>
</label>
<input class="form-control" id="cat" value="${requestScope.cat.name}" name="cat" readonly="" >
<input class="form-control" id="cat" value="${requestScope.cat.name}" name="cat" disabled >
</div>
</div>
<div class="col">
Expand Down

0 comments on commit 6aca169

Please sign in to comment.