Skip to content

Commit

Permalink
Merge pull request #488 from GroupProject-JOM/main
Browse files Browse the repository at this point in the history
Final presentation release
  • Loading branch information
Buddhikanip authored Apr 22, 2024
2 parents 46b5173 + b5a8445 commit 95168ca
Show file tree
Hide file tree
Showing 37 changed files with 1,350 additions and 280 deletions.
182 changes: 182 additions & 0 deletions admin/activity/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Distributors</title>

<!-- Primary Meta Tags -->
<meta name="title" content="Jayasinghe Oil Mills" />
<meta
name="description"
content="Jayasinghe Oil Mills Business and Manufacturing Process Management System."
/>
<meta
name="keywords"
content="JOM, Jayasinghe Oil Mills, Coconut Oil, Sri Lanaka"
/>

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content="https://jom-dev.duckdns.org/" />
<meta property="og:title" content="Jayasinghe Oil Mills" />
<meta
property="og:description"
content="Jayasinghe Oil Mills Business and Manufacturing Process Management System."
/>
<meta
property="og:image"
content="https://jom-dev.duckdns.org/common/img/logo-manifest.jpg"
/>

<!-- Twitter -->
<meta
property="twitter:card"
content="https://jom-dev.duckdns.org/common/img/logo-manifest.jpg"
/>
<meta property="twitter:url" content="https://jom-dev.duckdns.org/" />
<meta property="twitter:title" content="Jayasinghe Oil Mills" />
<meta
property="twitter:description"
content="Jayasinghe Oil Mills Business and Manufacturing Process Management System."
/>
<meta
property="twitter:image"
content="https://jom-dev.duckdns.org/common/img/logo-manifest.jpg"
/>

<!-- icons -->
<link
rel="apple-touch-icon"
sizes="180x180"
href="https://jom-dev.duckdns.org/common/img/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="https://jom-dev.duckdns.org/common/img/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="https://jom-dev.duckdns.org/common/img/favicon-16x16.png"
/>

<!-- manifest -->
<link rel="manifest" href="../../site.webmanifest" />

<script
src="https://kit.fontawesome.com/3d9946f29b.js"
crossorigin="anonymous"
></script>
<link rel="stylesheet" href="../../common/style.css" />
<link rel="stylesheet" href="../../common/nav.css" />
<link rel="stylesheet" href="../../common/notify.css" />
<link rel="stylesheet" href="../user-flow.css" />
<link
href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css"
rel="stylesheet"
/>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.min.css"
rel="stylesheet"
/>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<script src="../../common/func.js"></script>
<script src="../auth.js"></script>
</head>

<body>
<!-- Loading screen -->
<div class="loader-wrapper">
<div class="logo-container">
<img src="../../common/JOM logo 1.png" alt="" />
</div>
<div class="lds-spinner">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>

<nav class="sidebar"></nav>
<i class="fa fa-bars" aria-hidden="true"></i>

<section class="home">
<div class="notification">
<span class="count"></span>
<span class="bell do-not"
><i class="fa-regular fa-bell do-not"></i
></span>
</div>

<div class="notification-window do-not" id="notify"></div>

<div class="lng-picker">
<div class="sin">සිං</div>
<div class="en active">En</div>
</div>

<div class="text"></div>

<div class="salesmg-container activity-container">
<div class="salesmg-heading table-heading">
<h2 class="salesmg-title"></h2>
<div>
<p class="salesmg-text"></p>
<!-- Search Bar -->
<div class="search-filter">
<div class="search-wrapper">
<div class="search-box search-box">
<input type="text" class="search" placeholder=" " />
<span></span>
</div>
</div>
<!-- Search Bar -->

<div class="filter">
<div id="searchBox">
<i class="fas fa-filter" id="filter-icon"></i>
<input
type="date"
placeholder="Select date to filter"
id="datePicker"
/>
</div>
</div>
</div>
</div>
</div>

<div class="activity-content">
<table class="activity-table">
<tbody class="tbody"></tbody>
</table>
</div>
</div>

<div class="back-to-top">
<i class="fas fa-chevron-up"></i>
</div>
</section>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js"></script>
<script src="./script.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
<script src="../nav/load-nav.js"></script>
<script src="../notifications/load-notifications.js"></script>
<script src="../../common/loader.js"></script>
</body>
</html>
161 changes: 161 additions & 0 deletions admin/activity/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
document.cookie = "id=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
document.cookie = "dName=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
document.cookie = "dContact=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
document.cookie = "price=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
document.cookie = "visits=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";

(() => {
const body = document.querySelector("body"),
sin = body.querySelector(".sin"),
en = body.querySelector(".en"),
sTitle = body.querySelector(".salesmg-title"),
sText = body.querySelector(".salesmg-text"),
activityTable = body.querySelector(".activity-table"),
searchBar = body.querySelector(".search"),
datePicker = body.querySelector("#datePicker"),
tbody = body.querySelector(".tbody");

var lang = getCookie("lang"); // current language

var searchBa = document.querySelectorAll(
'.search-box input[type="text"] + span'
);

datePicker.value = new Date().toJSON().slice(0, 10);

datePicker.addEventListener("input", () => {
fetchData(datePicker.value);
});

searchBa.forEach((elm) => {
elm.addEventListener("click", () => {
elm.previousElementSibling.value = "";
search(searchBar.value.toUpperCase(), activityTable);
});
});

searchBar.addEventListener("keyup", () => {
search(searchBar.value.toUpperCase(), activityTable);
});

const searchBox = document.getElementById("searchBox"),
googleIcon = document.getElementById("filter-icon");

googleIcon.onclick = function () {
searchBox.classList.toggle("active");
};

sin.addEventListener("click", () => {
sin.classList.add("active");
en.classList.remove("active");

document.documentElement.setAttribute("lang", "sin");
document.cookie = "lang=sin; path=/";
lang = "sin";

sTitle.textContent = data["sin"]["sTitle"];
sText.innerHTML = data["sin"]["sText"];
setGreeting();
});

en.addEventListener("click", () => {
en.classList.add("active");
sin.classList.remove("active");

document.documentElement.setAttribute("lang", "en");
document.cookie = "lang=en; path=/";
lang = "en";

sTitle.textContent = data["en"]["sTitle"];
sText.innerHTML = data["en"]["sText"];
setGreeting();
});

var data = {
sin: {
sTitle: "ක්‍රියාකාරකම් ලොග",
sText: "සමාගම් බෙදාහරින්නන්ගේ සියලුම ක්‍රියාකාරකම් ලොග බලන්න",
},
en: {
sTitle: "Activity Logs",
sText: "View all activity logs of company distributors",
},
};

fetchData(new Date().toJSON().slice(0, 10));
function fetchData(date) {
var row = "";

fetch(backProxy + "/activity?date=" + date, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
credentials: "include",
})
.then((response) => {
if (response.status == 200) {
response.json().then((data) => {
let arr = data.activity;
arr.forEach(data_to_table);

function data_to_table(item) {
row +=
`<tr>` +
`<td>` +
`<div class="activity">` +
`<p class="activity-heading">` +
`<span class="quantity">${item.quantity}</span>` +
` <span class="name">${item.category}</span>` +
` <span class="type">${item.type}</span>s to ` +
` <span class="outlet">${item.outletName} ${item.area}</span> each for Rs.` +
`<span class="unit">${(
item.price / item.quantity
).toLocaleString("en-US")}</span>` +
`</p>` +
`<p class="activity-text">` +
`By` +
` <span class="distributor">${item.first_name} ${item.last_name}</span> on` +
` <span class="date">${item.date} at ${item.time}</span>.` +
` Received ` +
`<span class="total">Rs.${(+item.price).toLocaleString(
"en-US"
)}</span>` +
`</p>` +
`</div>` +
`</td>` +
`</tr>`;
}

tbody.innerHTML = row;
});
} else if (response.status === 202) {
response.json().then((data) => {
console.log(data.message);
if (lang == "sin")
Command: toastr["info"](date + " සඳහා ක්‍රියාකාරකම් ලොග නැත");
else Command: toastr["info"]("No activity logs for " + date);
});

tbody.innerHTML = row;
} else if (response.status === 401) {
response.json().then((data) => {
console.log(data.message);
});
if (lang == "sin") Command: toastr["error"]("වලංගු නොවන පරිශීලක");
else Command: toastr["error"]("Invalid User");

tbody.innerHTML = row;
} else {
console.error("Error:", response.status);
Command: toastr["error"](response.status, "Error");

tbody.innerHTML = row;
}
})
.catch((error) => {
console.error("An error occurred:", error);
Command: toastr["error"](error);
});
}
})();
6 changes: 6 additions & 0 deletions admin/nav/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
<span class="text nav-text l5"></span>
</a>
</li>
<li class="" id="nav-item-activity">
<a href="#" class="activity">
<i class="fa-solid fa-clipboard icon"></i>
<span class="text nav-text l12"></span>
</a>
</li>
</div>
<div class="bottom-content">
<span class="text nav-head l6"></span>
Expand Down
Loading

0 comments on commit 95168ca

Please sign in to comment.