-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from DasunThathsara/dasun
Add admin creation for superadmin
- Loading branch information
Showing
12 changed files
with
450 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,30 +17,31 @@ public function __construct(){ | |
// Register user | ||
public function register($data): bool | ||
{ | ||
$name = $data['name']; | ||
$email = $data['email']; | ||
|
||
// Prepare statement | ||
$this->mail->isSMTP(); //Send using SMTP | ||
$this->mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through | ||
$this->mail->SMTPAuth = true; //Enable SMTP authentication | ||
$this->mail->Username = '[email protected]'; //SMTP username | ||
$this->mail->Password = 'pcop yjvy adrx mlcl'; //SMTP password | ||
$this->mail->Port = 587; //TCP port to connect to; use 587 if you have set SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS | ||
|
||
//Recipients | ||
$this->mail->setFrom('[email protected]', 'Your One-Time Password (OTP) for eZpark Registration'); | ||
$this->mail->addAddress($email, $name); //Add a recipient | ||
|
||
//Attachments | ||
if ($data['user_type'] != 'admin'){ | ||
$name = $data['name']; | ||
$email = $data['email']; | ||
|
||
// Prepare statement | ||
$this->mail->isSMTP(); //Send using SMTP | ||
$this->mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through | ||
$this->mail->SMTPAuth = true; //Enable SMTP authentication | ||
$this->mail->Username = '[email protected]'; //SMTP username | ||
$this->mail->Password = 'pcop yjvy adrx mlcl'; //SMTP password | ||
$this->mail->Port = 587; //TCP port to connect to; use 587 if you have set SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS | ||
|
||
//Recipients | ||
$this->mail->setFrom('[email protected]', 'Your One-Time Password (OTP) for eZpark Registration'); | ||
$this->mail->addAddress($email, $name); //Add a recipient | ||
|
||
//Attachments | ||
// $mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments | ||
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name | ||
|
||
//Content | ||
$this->mail->isHTML(true); //Set email format to HTML | ||
$this->mail->Subject = 'Verification code'; | ||
$verification_code = substr(number_format(time() * rand(), 0, '', ''), 0, 6); | ||
$this->mail->Body = '<div id="overview" style="margin: auto; width: 80%; font-size: 13px"> | ||
//Content | ||
$this->mail->isHTML(true); //Set email format to HTML | ||
$this->mail->Subject = 'Verification code'; | ||
$verification_code = substr(number_format(time() * rand(), 0, '', ''), 0, 6); | ||
$this->mail->Body = '<div id="overview" style="margin: auto; width: 80%; font-size: 13px"> | ||
<p style="color: black"> | ||
Dear '.$name.',<br><br> | ||
|
@@ -55,9 +56,13 @@ public function register($data): bool | |
eZpark Team | ||
</p> | ||
</div>'; | ||
$this->mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; | ||
$this->mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; | ||
|
||
$this->mail->send(); | ||
$this->mail->send(); | ||
} | ||
else{ | ||
$verification_code = '000000'; | ||
} | ||
|
||
// Prepare statement | ||
$this->db->query('INSERT INTO user (name, username, email, password, userType, contactNo, otp, otpTime) VALUES (:name, :username, :email, :password, :userType, :contactNo, :otp, :otpTime)'); | ||
|
@@ -325,4 +330,23 @@ public function removeProfilePhoto(): bool | |
return false; | ||
} | ||
} | ||
|
||
// View all admins | ||
public function viewAdmins(){ | ||
$this->db->query('SELECT * FROM user WHERE userType = "admin"'); | ||
|
||
$results = $this->db->resultSet(); | ||
|
||
return $results; | ||
} | ||
|
||
// View specific admin | ||
public function viewAdmin($admin_id){ | ||
$this->db->query('SELECT * FROM user WHERE id = :id'); | ||
$this->db->bind(':id', $admin_id); | ||
|
||
$row = $this->db->single(); | ||
|
||
return $row; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="refresh" content="300"> | ||
<title><?php echo SITENAME ?></title> | ||
|
||
<!-- External CSS --> | ||
<link rel="stylesheet" href="<?php echo URLROOT ?>/css/style.css"> | ||
|
||
<!-- External js --> | ||
<script src="<?php echo URLROOT ?>/js/script.js" defer></script> | ||
</head> | ||
<body> | ||
|
||
<!-- Loading screen --> | ||
<div class="loader-wrapper"> | ||
<div class="logo-container"> | ||
<img src="<?php echo URLROOT ?>/images/logo.png" alt=""> | ||
</div> | ||
<div class="loader"></div> | ||
</div> | ||
|
||
<!-- TOP NAVIGATION --> | ||
<?php require APPROOT.'/views/inc/components/topnavbar.php'; ?> | ||
|
||
<!-- SIDE NAVIGATION --> | ||
<?php | ||
$section = 'dashboard'; | ||
require APPROOT.'/views/inc/components/sidenavbar.php'; | ||
?> | ||
|
||
<main class="page-container"> | ||
<section class="section" id="main"> | ||
<div class="container"> | ||
<h1>Dashboard</h1> | ||
|
||
<div class="cards"> | ||
<!-- Card 1 --> | ||
<a class="card-link" href="<?php echo URLROOT ?>/admin/viewRegistrationRequests"> | ||
<div class="card"> | ||
<div class="row"> | ||
<div class="left-col"> | ||
<div class="sub-row"> | ||
<div class="top-row"> | ||
<img src="<?php echo URLROOT ?>/images/parking.svg" alt=""> | ||
</div> | ||
<div class="bottom-row"><?php echo $data['request_count'] ?></div> | ||
</div> | ||
</div> | ||
<div class="right-col">Registration Requests</div> | ||
</div> | ||
</div> | ||
</a> | ||
|
||
<!-- Card 2 --> | ||
<a class="card-link" href="<?php echo URLROOT ?>/parkingOwner/parkingCapacity"> | ||
<div class="card"> | ||
<div class="row"> | ||
<div class="left-col"> | ||
<div class="sub-row"> | ||
<div class="top-row"> | ||
<img src="<?php echo URLROOT ?>/images/vehicle.svg" alt=""> | ||
</div> | ||
<div class="bottom-row">20</div> | ||
</div> | ||
</div> | ||
<div class="right-col">Complaints</div> | ||
</div> | ||
</div> | ||
</a> | ||
|
||
<!-- Card 3 --> | ||
<a class="card-link" href=""> | ||
<div class="card"> | ||
<div class="row"> | ||
<div class="left-col"> | ||
<div class="sub-row"> | ||
<div class="top-row"> | ||
<img src="<?php echo URLROOT ?>/images/dollar.svg" alt=""> | ||
</div> | ||
<div class="bottom-row"></div> | ||
</div> | ||
</div> | ||
<div class="right-col">Total Income</div> | ||
</div> | ||
</div> | ||
</a> | ||
</div> | ||
|
||
<div class="charts"> | ||
<h2>Analysis</h2> | ||
<div class="chart-container"> | ||
<div class="chart"> | ||
<canvas id="lineChart1" style="width:100%;max-width:600px"></canvas> | ||
</div> | ||
<div class="chart"> | ||
<canvas id="lineChart2" style="width:100%;max-width:600px"></canvas> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="open-side-cards-btn" onclick="closeRightCard()">View Transaction</div> | ||
|
||
<div class="side-cards"> | ||
<div class="close-btn" onclick="closeRightCard()">X</div> | ||
<h2>Recent Transaction</h2> | ||
|
||
<p><span>■</span>Today</p> | ||
|
||
<div class="side-card"> | ||
<div class="date-time">2023.11.22</div> | ||
<div class="parking">Nolimit</div> | ||
<div class="transaction-type in">In</div> | ||
</div> | ||
|
||
<div class="side-card"> | ||
<div class="date-time">2023.11.22</div> | ||
<div class="parking">Keels</div> | ||
<div class="transaction-type out">Out</div> | ||
</div> | ||
|
||
<div class="side-card"> | ||
<div class="date-time">2023.11.22</div> | ||
<div class="parking">Nolimit</div> | ||
<div class="transaction-type in">In</div> | ||
</div> | ||
|
||
<div class="side-card"> | ||
<div class="date-time">2023.11.22</div> | ||
<div class="parking">Keels</div> | ||
<div class="transaction-type out">Out</div> | ||
</div> | ||
|
||
<p><span>■</span>Yesterday</p> | ||
|
||
<div class="side-card"> | ||
<div class="date-time">2023.11.22</div> | ||
<div class="parking">Nolimit</div> | ||
<div class="transaction-type in">In</div> | ||
</div> | ||
|
||
<div class="side-card"> | ||
<div class="date-time">2023.11.22</div> | ||
<div class="parking">Keels</div> | ||
<div class="transaction-type out">Out</div> | ||
</div> | ||
|
||
<div class="side-card"> | ||
<div class="date-time">2023.11.22</div> | ||
<div class="parking">Nolimit</div> | ||
<div class="transaction-type in">In</div> | ||
</div> | ||
|
||
<div class="side-card"> | ||
<div class="date-time">2023.11.22</div> | ||
<div class="parking">Keels</div> | ||
<div class="transaction-type out">Out</div> | ||
</div> | ||
</div> | ||
</section> | ||
</main> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script> | ||
<script> | ||
const xValues = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov', 'dec']; | ||
const yValues = [7,8,8,9,9,9,10,11,14,14,15]; | ||
|
||
var xValues2 = ["Italy", "France", "Spain", "USA", "Argentina"]; | ||
var yValues2 = [55, 49, 44, 24, 15]; | ||
var barColors = ["red", "green","blue","orange","brown"]; | ||
|
||
new Chart("lineChart1", { | ||
type: "line", | ||
data: { | ||
labels: xValues, | ||
datasets: [{ | ||
fill: false, | ||
lineTension: 0, | ||
backgroundColor: "rgb(0,0,0)", | ||
borderColor: "rgb(252,212,38)", | ||
data: yValues | ||
}] | ||
}, | ||
options: { | ||
legend: {display: false}, | ||
scales: { | ||
yAxes: [{ticks: {min: 6, max:16}}], | ||
} | ||
} | ||
}); | ||
|
||
// Create a new chart with a different id for the second canvas | ||
new Chart("lineChart2", { | ||
type: "bar", | ||
data: { | ||
labels: xValues, | ||
datasets: [{ | ||
backgroundColor: barColors, | ||
data: yValues | ||
}] | ||
}, | ||
options: { | ||
legend: {display: false}, | ||
title: { | ||
display: true, | ||
text: "Vehicle Count" | ||
} | ||
} | ||
}); | ||
</script> | ||
|
||
<?php require APPROOT.'/views/inc/footer.php'; ?> |
Oops, something went wrong.