Skip to content

Commit

Permalink
sector api and generation functional
Browse files Browse the repository at this point in the history
  • Loading branch information
noiia committed Mar 23, 2024
1 parent 8fb23b1 commit 57f3ad6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
32 changes: 17 additions & 15 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,35 +101,36 @@

$entityManager = $container->get(EntityManager::class);
$company = $entityManager->getRepository(Company::class)->findOneBy(['ID_company' => $args['i']]);
$i = 0;

$Sectors = [];
foreach ($company->getSector() as $sector) {
$i++;
if ($i <= 3) {
$Sectors[] = $sector->getName();
} else {
break;
}
$Sectors[] = $sector->getName();
}

$Internships = [];
$i = 0;
foreach ($company->getInternship() as $internship) {
$i++;
$Internships[] =
[
'title' => $internship->getTitle(),
'location' => $internship->locations->getCity(),
'starting_date' => $internship->getStartingDate(),
'duration' => $internship->getDuration(),
];
[
'title' => $internship->getTitle(),
'location' => $internship->locations->getCity(),
'starting_date' => $internship->getStartingDate(),
'duration' => $internship->getDuration(),
];
}

$j = 0;
$medium = 0;
$Comments = [];
if ($company->getRates() != null){
foreach ($company->getRates() as $rate) {
$medium = $rate->getNote();
$medium += $rate->getNote();
$j++;
$Comments[] =
['note' => $rate->getNote(),
[
'user' => $rate->users->getName(),
'note' => $rate->getNote(),
'description' => $rate->getDescription(),
];
}
Expand All @@ -151,6 +152,7 @@
'sector' => $Sectors,
'internship' => $Internships,
'comment' => $Comments,
'number_of_internship' => $i,
//'logo_path' => $imagePath,
];

Expand Down
19 changes: 11 additions & 8 deletions public/js/Company.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,28 @@ function loadCompanyBubbleData(id = 1){
const bubbleContainer = document.getElementById("bubble-place");
const bubbleTemplate = mainTemplate.content.cloneNode(true);

bubbleTemplate.getElementById("Big-bubble-name").textContent = data.Name;
bubbleTemplate.getElementById("Big-bubble-name").textContent = data.company;
bubbleTemplate.getElementById("Big-bubble-location").textContent = data.zip_code + ' - ' + data.location;
bubbleTemplate.getElementById("Big-bubble-number-student").textContent = data.number_former_intern + ' étudiants';
bubbleTemplate.getElementById("rangeValue2").textContent = data.medium_rate;
bubbleTemplate.getElementById("rangeInput2").value = data.medium_rate;
bubbleTemplate.getElementById("Big-bubble-description").textContent = data.description;
bubbleTemplate.getElementById("internship-number").textContent = data.number_of_internship + " stages disponibles:";
//bubbleTemplate.getElementById("Big-bubble-logo").src = data.logo_path;
bubbleContainer.append(bubbleTemplate);

const miniInternshipTemplate = document.getElementById("mini-internship");
//const sectorTemplate = document.getElementById("sector-template");
const sectorTemplate = document.getElementById("sector-template");
const commentTemplate = document.getElementById("comment-template");
const sectorContainer = document.getElementById("container-company-details-sector-name");
const sectorContainer = document.getElementById("container-company-details-sector-name-list");
const internshipContainer = document.getElementById("mini-internship-container");
const commentContainer = document.getElementById("comment-container");

/*for (let sector of data.sector) {
for (let sector of data.sector) {
const cloneSectorTemplate = sectorTemplate.content.cloneNode(true);
sectorTemplate.getElementById("sector-ref").textContent = sector;
sectorContainer.append(sectorTemplate);
}*/
cloneSectorTemplate.getElementById("sector-ref").textContent = sector;
sectorContainer.append(cloneSectorTemplate);
}
for (let internship of data.internship) {
const cloneInternshipTemplate = miniInternshipTemplate.content.cloneNode(true);
cloneInternshipTemplate.getElementById("internship-title").textContent = internship.title;
Expand All @@ -42,7 +44,8 @@ function loadCompanyBubbleData(id = 1){
}
for (let comment of data.comment) {
const cloneCommentTemplate = commentTemplate.content.cloneNode(true);
cloneCommentTemplate.getElementById("comment-ref").textContent = comment;
cloneCommentTemplate.getElementById("comment-user").textContent = comment.user + " - " + comment.note + "/10";
cloneCommentTemplate.getElementById("comment-description").textContent = comment.description;
commentContainer.append(cloneCommentTemplate);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Rate.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Rate
private ?Company $companies;
#[ManyToOne(targetEntity: Users::class, inversedBy: "users")]
#[JoinColumn(name: "ID_users", referencedColumnName: "ID_users")]
private ?Users $users;
public ?Users $users;

public function getIDRate(): int
{
Expand Down
13 changes: 8 additions & 5 deletions templates/Company/Company.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,14 @@
<p>Note moyenne:&nbsp<p id="rangeValue2"></p>/10</p>
</div>
<div class="container-company-details-note-bar">
<input type="range" min="1" max="10" step="1" id="rangeInput2" value="4" disabled oninput="rangeValue2.innerText = this.value">
<input type="range" min="1" max="10" step="0.1" id="rangeInput2" value="4" disabled oninput="rangeValue2.innerText = this.value">
</div>
<div class="container-company-details-sector">
<h1>Secteurs d'activités de l'entreprise:</h1>
</div>
<div class="container-company-details-sector-name">
<ul id="container-company-details-sector-name-list">
</ul>
</div>
</div>
</div>
Expand All @@ -180,7 +182,7 @@
<p id="Big-bubble-description"></p>
</div>
<div class="container-company-details-intern-name">
<h1>4 stages disponibles:</h1>
<h1 id="internship-number"></h1>
</div>
<div class="container-company-details-intern-second-scrollbar" id="mini-internship-container">
<!---------------------------- ici pour les mini stages ---------------------------->
Expand Down Expand Up @@ -214,9 +216,7 @@
<div id="bubble-place">
</div>
<template id="sector-template">
<ul>
<li id="sector-ref"></li>
</ul>
</template>

<template id="mini-internship">
Expand All @@ -241,7 +241,10 @@
</template>
<template id="comment-template">
<div class="container-company-each-review-name">
<h1>LAUMEL Stéphan - 0/10</h1>
<h1 id="comment-user"></h1>
</div>
<div class="container-company-each-review">
<p id="comment-description"></p>
</div>
</template>
</div>
Expand Down

0 comments on commit 57f3ad6

Please sign in to comment.