Commit 2750e609 by Mihailo Sebek

Merge remote-tracking branch 'origin/master'

parents e3fda47b fbc8a1cb
......@@ -94,8 +94,15 @@ public class OglasController
model.addAttribute("slike", sRepo.findAllById( oglasId));
model.addAttribute("grad", kRepo.findCity( oglas.getLokacijaId()));
model.addAttribute("noviZahtev", new Zahtev());
if( loggedUser != null && oglas.getKorisnikId() == loggedUser.getKorisnik().getKorisnikId())
model.addAttribute("zahtevi", zRepo.findAllByOglasId( oglasId));
if( loggedUser != null && oglas.getKorisnikId() == loggedUser.getKorisnik().getKorisnikId()) {
List<Zahtev> zahtevi = zRepo.findAllByOglasId(oglasId);
List<Korisnik> korisnici = new ArrayList<Korisnik>();
for( Zahtev zahtev: zahtevi)
korisnici.add( kRepo.findById( zahtev.getKorisnikId()));
model.addAttribute("zahtevi", zahtevi);
model.addAttribute("korisnici", korisnici);
}
return("oglas");
}
@GetMapping("/profile/moji-oglasi")
......
......@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.Date;
......@@ -30,9 +31,10 @@ public class ZahtevController {
}
@PostMapping("/obradi-zahtev/{id}")
public String postObradizahtev(Model model, @AuthenticationPrincipal KorisnikDetails loggedUser, @ModelAttribute Zahtev noviZahtev, @ModelAttribute("datumIVreme") String datumIVreme, @PathVariable("id") int oglasId)
public String postObradizahtev(Model model, @AuthenticationPrincipal KorisnikDetails loggedUser, @ModelAttribute Zahtev noviZahtev, @ModelAttribute("datumIVreme") String datumIVreme, @PathVariable("id") int oglasId, RedirectAttributes redirectAttributes)
{
zRepo.insert( loggedUser.getKorisnik().getKorisnikId(), oglasId, noviZahtev, datumIVreme);
redirectAttributes.addFlashAttribute("zakazan",true);
return "redirect:/lista-oglasa/"+oglasId;
}
......@@ -42,4 +44,17 @@ public class ZahtevController {
return "redirect:/lista-oglasa/"+oglasId;
}
@GetMapping("/oglas-edit/{oglasId}/prihvati-zahtev/{zahtevId}")
public String getPrihvatiZahtev( Model model, @PathVariable("oglasId") int oglasId, @PathVariable("zahtevId") int zahtevId)
{
zRepo.updateZahtevStatus( zahtevId, StanjeZahteva.POTVRDJEN);
return ("redirect:/lista-oglasa/" + oglasId);
}
@GetMapping("/oglas-edit/{oglasId}/odbi-zahtev/{zahtevId}")
public String getOdbiZahtev( Model model, @PathVariable("oglasId") int oglasId, @PathVariable("zahtevId") int zahtevId)
{
zRepo.updateZahtevStatus( zahtevId, StanjeZahteva.ODBIJEN);
return ("redirect:/lista-oglasa/" + oglasId);
}
}
......@@ -96,4 +96,18 @@ public class ZahtevRepository {
throw new RuntimeException(e);
}
}
public void updateZahtevStatus(int zahtevId, StanjeZahteva potvrdjen)
{
String sql = "{ call updateZahtevStatus(?,?)}";
CallableStatement cs = null;
try {
cs = dataBase.connection.prepareCall(sql);
cs.setInt(1, zahtevId);
cs.setString(2, potvrdjen.toString());
cs.execute();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
......@@ -326,6 +326,12 @@ p {
border-radius: 50%;
object-fit: cover;
}
#slikaProfil1{
width: 150px;
height: 150px;
border-radius: 50%;
object-fit: cover;
}
.fab.fa-twitter {
color: #8ab7f1;
......@@ -513,6 +519,7 @@ p {
height: 100%;
}
.pozadinaSlika{
/*background-image:*/
background-image:url("https://wallpaperaccess.com/full/1895610.jpg");
background-repeat: no-repeat;
background-size: cover;
}
\ No newline at end of file
......@@ -97,7 +97,7 @@
<div class="row justify-content-center w-100">
<div class="col d-flex justify-content-center align-items-center">
<div class="text-center text-white w-100">
<h1 class="mb-5" style="color:black">Pretrazite oglase</h1>
<h1 class="mb-5" style="color:white">Pretrazite oglase</h1>
<form class="form-subscribe" method="GET" th:action="@{/lista-oglasa}">
<div class="row">
<div class="col-3">
......@@ -109,11 +109,11 @@
</div>
<div class="col-3">
<input type="radio" name="vrstaOglasaId" id="radiodugme1" value="1">
<label for="radiodugme1" style="color:black">Prodaja</label>
<label for="radiodugme1" style="color:white">Prodaja</label>
</div>
<div class="col-3">
<input type="radio" name="vrstaOglasaId" id="radiodugme2" value="2">
<label for="radiodugme2" style="color:black">Iznajmljivanje</label>
<label for="radiodugme2" style="color:white">Iznajmljivanje</label>
</div>
<div class="col-3">
<button class="btn btn-secondary btn-lg" id="submitButton" type="submit">Pretrazi
......
......@@ -104,9 +104,9 @@
<div class="card mb-3" th:each="korisnik: ${korisnici}">
<div class="row no-gutters">
<div class="col-md-4 d-flex justify-content-center align-items-center">
<img style="width: 150px;height: 150px"
<img
th:src="@{'data:image/png;charset=utf-8;base64,'+${korisnik.getSlika()}}"
alt="slika korisnika">
alt="slika korisnika" id="slikaProfil1">
</div>
<div class="col-md-6">
<div class="card-body">
......
......@@ -88,6 +88,10 @@
</nav>
<div class="mt-5 ml-5 mr-0 w-100" th:object="${oglasId}">
<div class="alert alert-success d-flex justify-content-between align-items-center" th:object="${zakazan}" th:if="${zakazan == true}" style="width: 96%">
<div><strong>Uspesno!</strong> Uspesno ste poslali zahtev za obilazak!</div>
<button type="button" class="btn-close" data-dismiss="alert"></button>
</div>
<div class="row mb-5 flex-row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div id="custCarousel" class="carousel slide" data-ride="carousel" align="center">
......@@ -166,7 +170,7 @@
</div>
</div>
</div>
<div class="row">
<div class="row" th:if="${(loggedUser !=null) && (oglas.korisnikId != loggedUser.getKorisnik().korisnikId)}">
<button type="button" class="btn btn-primary" id="zahtevDugme" >Zakazite obilazak</button>
<div class="row mt-3" id = "izlazDiv" style="display: none;">
<form class="d-flex justify-content-center flex-column align-items-end" th:if="${loggedUser != null}" th:action="@{/obradi-zahtev/{id}(id=${oglasId})}" method="POST" th:object="${noviZahtev}">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment