Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions BackEnd/Library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
<version>1.8</version>
</dependency>

<dependency>
<groupId>net.sf.supercsv</groupId>
<artifactId>super-csv</artifactId>
<version>2.4.0</version>
</dependency>



</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,19 @@ public List<Object[]> getcountByCategoryId() {

}


@GetMapping("/admin/searchBooks")
public ResponseEntity<Page<Books>> getAllBookStockSearch(
@RequestParam(defaultValue = "") String keyword,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy) {
System.out.println("paage size" + pageSize);
Page<Books> list = service.getAllBookStocks(keyword, pageNo - 1, pageSize, sortBy);
return new ResponseEntity<Page<Books>>(list, new HttpHeaders(),
HttpStatus.OK);

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import java.util.Collection;
import java.sql.Date;
import java.util.List;
import java.io.IOException;

import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import javax.validation.Valid;

Expand All @@ -21,6 +28,13 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



import org.supercsv.io.CsvBeanWriter;
import org.supercsv.io.ICsvBeanWriter;
import org.supercsv.prefs.CsvPreference;


import com.innovature.Library.entity.Borrow;
import com.innovature.Library.form.BorrowForm;
import com.innovature.Library.service.BorrowService;
Expand Down Expand Up @@ -289,6 +303,45 @@ public BorrowDetailView updatePaymentStatus(



@GetMapping("admin/export")
public void Exportcsv(HttpServletResponse httpServletResponse) throws IOException {
httpServletResponse.setContentType("text/csv");
java.text.DateFormat datefFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String currentDateTime = datefFormat.format(new java.util.Date());
String headerKey = "Content-Disposition";
String headerValue = "attachment; filename=users_" + currentDateTime + ".csv";
httpServletResponse.setHeader(headerKey, headerValue);
List<Borrow> rents = bService.listcsv();

ICsvBeanWriter csvWriter = new CsvBeanWriter(httpServletResponse.getWriter(),
CsvPreference.STANDARD_PREFERENCE);
String[] csvHeader = { "borrow_id","first_name","books_name", "issue_date", "return_date","due_date","book_returned_date","reason","due_days","fine","status"};
String[] nameMapping = { "borrowId","firstName","booksName", "issueDate", "returnDate", "dueDate","bookReturnedDate","reason","dueDays","fine","status" };
csvWriter.writeHeader(csvHeader);
for (Borrow rent : rents) {
// System.out.println(" :"+rent.getStatus());
csvWriter.write(rent, nameMapping);
}
csvWriter.flush();
csvWriter.close();
}


// @GetMapping("/admin/searchUser")
// public ResponseEntity<Page<Borrow>> getAllBorrowedUserSearch(
// @RequestParam(defaultValue = "") String keyword,
// @RequestParam(defaultValue = "1") Integer pageNo,
// @RequestParam(defaultValue = "10") Integer pageSize)
// // @RequestParam(defaultValue = "user_id") String sortBy)
// {
// System.out.println("paage size" + pageSize);
// Page<Borrow> list = bService.getAllBorrowedUserSearch(keyword, pageNo - 1, pageSize);
// return new ResponseEntity<Page<Borrow>>(list, new HttpHeaders(),
// HttpStatus.OK);

// }




}
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ public Borrow(BorrowForm form, Books books, User user2) {

public Borrow(Books book, User user) {
this.books = book;
this.user = user;
this.user = user;
this.status = "REQUESTED";
this.paymentStatus="UNBILLED";
this.reason = "NA";
this.dueDays=(long) 0;
this.fine=(long) 0;
}
Expand Down Expand Up @@ -192,4 +193,12 @@ public void setPaymentStatus(String paymentStatus) {
this.paymentStatus = paymentStatus;
}

public String getFirstName(){
return user.getFirstName();
}

public String getBooksName(){
return books.getBooksName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ public interface BooksRepository extends Repository<Books, Integer> {
// @Query(value = "select sum(books_copies)", nativeQuery = true)
// List<Object[]> findbyBooksId1();

@Query(value = "Select * from books where status = 1 AND books_name like %?1% order by books_name like ?2% DESC,books_name like %?3 DESC,books_name like %?4% ", nativeQuery = true)
public Page<Books> findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable);


}
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public interface BorrowRepository extends PagingAndSortingRepository<Borrow, Int
Integer findbyUserIdAndStatus(Integer userId);


@Query(value = "SELECT * FROM borrow",nativeQuery = true)
List<Borrow>findAllC();
// @Query(value = "SELECT * FROM borrow",nativeQuery = true)
// List<Borrow>findAllC();

// @Query(value = "select * from borrow where issue_date between date_sub(curdate(),interval 7 day) and curdate()",nativeQuery = true)
// List<Borrow>findAllC();
Expand All @@ -126,9 +126,28 @@ public interface BorrowRepository extends PagingAndSortingRepository<Borrow, Int
public Page<Borrow> findByReqStatusUser(Integer userId,Pageable paging);




}

//mysql> select count(borrow_id) from borrow where book_returned_date between '2023-01-01' and '2023-01-07';
//select count(borrow_id) from borrow where book_returned_date='2022-12-27';
@Query(value = "SELECT * FROM borrow",nativeQuery = true)
List<Borrow>findAllC();

@Query(value = "select * from borrow where issue_date between date_sub(curdate(),interval 7 day) and curdate()",nativeQuery = true)
List<Borrow>findAllL7();

// @Query(value = "Select * from borrow where books_name like %?1% order by books_name like ?2% DESC,books_name like %?3 DESC,books_name like %?4% ", nativeQuery = true)
// public Page<Borrow> findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable);


// @Query(value = "SELECT * FROM borrow INNER JOIN user ON borrow.user_id = user.user_id where first_name like %?1% order by first_name like ?2% DESC,first_name like %?3 DESC,first_name like %?4% ", nativeQuery = true)
// public Page<Borrow> findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable);

// @Query(value = "select * from borrow where user_id in(select user_id from user where first_name like %?%", nativeQuery = true)
// public Page<Borrow> findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable);


}

//mysql> select count(borrow_id) from borrow where book_returned_date between '2023-01-01' and '2023-01-07';
//select count(borrow_id) from borrow where book_returned_date='2022-12-27';

// inner join eg = SELECT user.first_name FROM borrow INNER JOIN user ON borrow.user_id = user.user_id
// >no innerjoin= select user.first_name from user,borrow where user.user_id=borrow.user_id;
//>select * from borrow where user_id in(select user_id from user where first_name like 'ashwin');
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public interface BooksService {

List<Object[]> getBookCountByCategory();

Page<Books>getAllBookStocks(String keyword, Integer pageNo,Integer pageSize,String sortBy);

}


Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public interface BorrowService {

BorrowDetailView updatePaymentStatus(Integer borrowId, BorrowForm form);

List<Borrow>listcsv();

// Page<Borrow>getAllBorrowedUserSearch(String keyword, Integer pageNo,Integer pageSize);
// public RentCharView getChart();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,19 @@ public RedirectView uploadImage(MultipartFile multipartFile) throws IOException
public List<Object[]> getBookCountByCategory() {
return booksRepository.findCountByCategoryId();
}
//book search

@Override
public Page<Books> getAllBookStocks(String keyword, Integer pageNo, Integer pageSize, String sortBy) {
Pageable paging = PageRequest.of(pageNo, pageSize, Sort.by(sortBy));
System.out.println(keyword);
String k = keyword;
String k1 = keyword;
String k2 = keyword;
Page<Books> pagedResult = booksRepository.findByKeywords(keyword, k, k1, k2, paging);
return pagedResult;

}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public BorrowDetailView updates(Integer borrowId, BorrowForm form) {
borrow.setIssueDate(LocalDateTime.now());
borrow.setDueDate(form.getDueDate());
borrow.setReturnDate(form.getReturnDate());
borrow.setReason(null);
borrow.setReason("NA");
borrow.setStatus("APPROVED");
books.setBooksCopies(books.getBooksCopies() - 1);
return new BorrowDetailView(borrowRepository.save(borrow));
Expand Down Expand Up @@ -395,10 +395,10 @@ public rentChartView getChart() {
hm.put(6, new Result(0, 0));
hm.put(7, new Result(0, 0));

List<Borrow> s = borrowRepository.findAllC();
List<Borrow> s = borrowRepository.findAllL7();

for (Borrow a : s) {
if (a.getStatus().equals("APPROVED")) {
if(a.getIssueDate()!=null) {

LocalDateTime b = a.getIssueDate();
System.out.println("---------------------------" + b);
Expand Down Expand Up @@ -522,4 +522,30 @@ public BorrowDetailView updatePaymentStatus(Integer borrowId, BorrowForm form) {
return new BorrowDetailView(borrowRepository.save(borrow));
}

@Override
public List<Borrow> listcsv() {
return borrowRepository.findAllC();
}


// @Override
// public Page<Borrow> getAllBorrowedUserSearch(String keyword, Integer pageNo, Integer pageSize) {
// Pageable paging = PageRequest.of(pageNo, pageSize);
// System.out.println(keyword);
// String k = keyword;
// String k1 = keyword;
// String k2 = keyword;
// Page<Borrow> pagedResult = borrowRepository.findByKeywords(keyword, k, k1, k2, paging);
// return pagedResult;

// }









}
11 changes: 4 additions & 7 deletions FrontEnd/Library/src/app/addbooks/addbooks.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
<input type="text" style="position: relative; left:1030px; top:-75px;" class="form-control" formControlName="inp" placeholder="Enter Book Name to Search "
aria-label="Recipient's username" aria-describedby="basic-addon2" (ngModelChange)="search1(this.search.controls['inp'].value)" >
<button mat-icon-button style="position: relative; left:1030px; top:-75px;"> <i class="material-icons" style="color:rgb(0, 0, 0)" >search</i></button>
<!-- <div class="input-group-append">
<button class="input-group-text button_" id="basic-addon2" (click)="search1(this.search.controls['inp'].value)">search</button>
</div> -->

</form>


Expand All @@ -23,8 +21,7 @@
<button mat-icon-button [disabled]="!selectedFiles" > <i class="material-icons" style="color:rgb(142, 179, 137);" (click)="upload() " >cloud_upload</i></button>
</div>

<!-- <div class="card-box">
<div class="row"> -->

<div class="table-responsive">
<table align="center" class=".table-hover" >
<thead class="bg-primary text-white">
Expand Down Expand Up @@ -84,8 +81,8 @@
</table>
<!-- unfold_more -->
</div>
<!-- </div>
</div> -->


<!-- Pagenation Controler -->
<div class="d-flex justify-content-center">
<pagination-controls (pageChange)="onTableDataChange(page=$event)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h2 style="text-align:center ;">Borrow Details</h2>
<tr> <td>DUE DATE </td><td>:</td> <td>{{this.borrowdata.dueDate| date:'dd/MM/yyyy'}}</td>
<tr> <td>DUE DAYS </td><td>:</td> <td>{{this.borrowdata.dueDays}}</td>
<tr> <td>FINE (INR) </td><td>:</td> <td>{{this.borrowdata.fine}}</td>
<tr> <td>PAYMENT </td><td>:</td> <td>{{this.borrowdata.paymentStatus}}</td>
<tr> <td>RETURNED DATE </td><td>:</td><td>{{this.borrowdata.bookReturnedDate| date:'dd/MM/yyyy'}}</td>
<tr> <td>STATUS </td><td>:</td> <td>{{this.borrowdata.status}}</td>
<tr> <td>Reason</td><td>:</td> <td>{{this.borrowdata.reason}}</td></tr>
Expand Down
4 changes: 2 additions & 2 deletions FrontEnd/Library/src/app/borrow/borrow.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ <h2 style="text-align:center ;">Borrow Details</h2>
<td>{{post.books.booksName}}</td>
<td>{{post.issueDate| date:'dd/MM/yyyy'}}</td>
<td>{{post.dueDate| date:'dd/MM/yyyy'}}</td>
<td>{{post.fine}}</td>
<td>{{post.status}}</td>
<td>{{post.fine }} ( {{post.paymentStatus}} )</td>
<td>{{post.status}} </td>

<td>
<button mat-button (click)="acceptRequest(post)" color="primary" *ngIf="post.status=='REQUESTED' " >Accept</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h1 style="text-align:center ;">Borrow Details</h1>
<th>Reason</th>
<th>DueDays</th>
<th>Fine(INR)</th>
<th>Payment</th>
</tr>

</thead>
Expand All @@ -69,6 +70,7 @@ <h1 style="text-align:center ;">Borrow Details</h1>
<td>{{borrow.reason}}</td>
<td>{{borrow.dueDays}}</td>
<td>{{borrow.fine}}</td>
<td>{{borrow.paymentStatus}}</td>
</tbody>
</table>
<div class="d-flex justify-content-center">
Expand Down
14 changes: 3 additions & 11 deletions FrontEnd/Library/src/app/sidenav2/sidenav2.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<app-navbar2></app-navbar2>
<router-outlet></router-outlet>
<head>
</head>

<div class="area"></div>
<nav class="main-menu" >
<ul>
Expand Down Expand Up @@ -47,14 +46,7 @@
</span><br>
</a>
</li>
<!-- <li>
<a href="#">
<i class="fa fa-bell fa-2x"></i>
<span class="nav-text">
Member Map
</span>
</a>
</li> -->


</ul>

Expand All @@ -66,7 +58,7 @@
<span class="nav-text" (click)="logout()">
Logout
</span>
<!-- </button> -->

</a>
</li>
</ul>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.