Skip to content

Commit

Permalink
Final Add
Browse files Browse the repository at this point in the history
  • Loading branch information
shingareom committed Mar 19, 2024
1 parent 39acaeb commit b3c1e65
Show file tree
Hide file tree
Showing 19 changed files with 455 additions and 560 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Welcome to the Government Polytechnic College Dharashiv Office Management System
## Contributors

- [Om Shingare](https://github.com/ShingareOm) - Developer
- [Prerana Kupade](https://github.com/PreranaKupade) - Developer

## Support

Expand Down
32 changes: 16 additions & 16 deletions admin_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function update_user(){
extract($_POST);
$data = "";
foreach($_POST as $k => $v){
if(!in_array($k, array('id','cpass','table','password')) && !is_numeric($k)){
if(!in_array($k, array('user_id','user_password','table','user_password')) && !is_numeric($k)){

if(empty($data)){
$data .= " $k='$v' ";
Expand All @@ -219,7 +219,9 @@ function update_user(){
}
}
}
$check = $this->db->query("SELECT * FROM users where email ='$email' ".(!empty($id) ? " and id != {$id} " : ''))->num_rows;

// echo "user id is {$user_id}";
$check = $this->db->query("SELECT * FROM gpd_users where user_email ='$user_email' ".(!empty($user_id) ? " and user_id != {$user_id} " : ''))->num_rows;
if($check > 0){
return 2;
exit;
Expand All @@ -229,17 +231,18 @@ function update_user(){
$move = move_uploaded_file($_FILES['user_profile_pic']['tmp_name'],'assets/uploads/'. $fname);
$data .= ", user_profile_pic = '$fname' ";
}
if(!empty($password))
$data .= " ,password=md5('$password') ";
if(empty($id)){
$save = $this->db->query("INSERT INTO users set $data");
if(!empty($user_password))
$data .= " ,user_password=md5('$user_password') ";
// echo "This is userid {$user_id}";
if(empty($user_id)){
$save = $this->db->query("INSERT INTO gpd_users set $data");
}else{
$save = $this->db->query("UPDATE users set $data where id = $id");
$save = $this->db->query("UPDATE gpd_users set $data where user_id = $user_id");
}

if($save){
foreach ($_POST as $key => $value) {
if($key != 'password' && !is_numeric($key))
if($key != 'user_password' && !is_numeric($key))
$_SESSION['login_'.$key] = $value;
}
if(isset($_FILES['img']) && !empty($_FILES['img']['tmp_name']))
Expand All @@ -250,7 +253,6 @@ function update_user(){
function delete_user(){
extract($_POST);
$delete = $this->db->query("DELETE FROM gpd_users where user_id = '$id'");
// return "DELETE FROM gpd_users where user_id = '$id'";
if($delete)
return 1;
}
Expand Down Expand Up @@ -356,28 +358,26 @@ function save_task(){
extract($_POST);
$data = "";
foreach($_POST as $k => $v){
if(!in_array($k, array('id')) && !is_numeric($k)){
if($k == 'description')
$v = htmlentities(str_replace("'","’",$v));
if(!in_array($k, array('letter_id')) && !is_numeric($k)){
if(empty($data)){
$data .= " $k='$v' ";
}else{
$data .= ", $k='$v' ";
}
}
}
if(empty($id)){
$save = $this->db->query("INSERT INTO task_list set $data");
if(empty($letter_id)){
return 2;
}else{
$save = $this->db->query("UPDATE task_list set $data where id = $id");
$save = $this->db->query("UPDATE gpd_letters set $data where letter_id = $letter_id");
}
if($save){
return 1;
}
}
function delete_task(){
extract($_POST);
$delete = $this->db->query("DELETE FROM task_list where id = $id");
$delete = $this->db->query("DELETE FROM gpd_letters where letter_id = $letter_id");
if($delete){
return 1;
}
Expand Down
Binary file modified assets/images/gpdbackground.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/uploads/1710817860_IMG_20220921_134754.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
10 changes: 6 additions & 4 deletions home.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="col-md-8">
<div class="card card-outline card-success">
<div class="card-header">
<b>Project Progress</b>
<b>Letter Progress</b>
</div>
<div class="card-body p-0">
<div class="table-responsive">
Expand Down Expand Up @@ -47,7 +47,9 @@
$where = " WHERE letter_creator_user_id = '{$_SESSION['login_user_id']}'";
}
elseif($_SESSION['login_user_type_id'] == 3){
$where = " WHERE letter_creator_user_id = '{$_SESSION['login_user_id']}'";
// $where = " WHERE letter_creator_user_id = '{$_SESSION['login_user_id']}'";
$where = " WHERE letter_status = 2 AND letter_creator_user_id IN ( SELECT user_id FROM gpd_teacher WHERE department_id = ( SELECT department_id FROM gpd_hod WHERE user_id = '{$_SESSION['login_user_id']}' ))";

}
elseif($_SESSION['login_user_type_id'] == 4){
$where = " WHERE letter_status = '3'";
Expand All @@ -58,7 +60,7 @@
$qry = $conn->query("SELECT * FROM gpd_letters $where order by letter_creator_user_id asc");
while($row = $qry->fetch_assoc()):
$status = $row['letter_status'];
$prog = ($status == 4) ? 100 : ($status * 25); // Assuming Done is 100%
$prog = ($status == 4) ? 100 : ($status * 20); // Assuming Done is 100%

?>
<tr>
Expand Down Expand Up @@ -89,7 +91,7 @@
?>
</td>
<td>
<a class="btn btn-primary btn-sm" href="./index.php?page=view_project&id=<?php echo $row['letter_id'] ?>">
<a class="btn btn-primary btn-sm" href="./index.php?page=view_letter&id=<?php echo $row['letter_id'] ?>">
<i class="fas fa-folder">
</i>
View
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

<!-- Main Footer -->
<footer class="main-footer">
<strong>Designed by Copyright &copy; 2024 <a href="https://www.omshingare.me/">omshingare.me</a></strong>
<strong>Designed by <a href="https://www.omshingare.me/">omshingare.me</a> havin' Copyright &copy; 2024 - <?php $current_year = date('Y'); echo $current_year;?> </strong>
<div class="float-right d-none d-sm-inline-block">
<b><?php echo $_SESSION['system']['name'] ?></b>
</div>
Expand Down
8 changes: 4 additions & 4 deletions letter_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if (!in_array($_SESSION['login_user_type_id'], $array)): ?>
<div class="card-tools">
<a class="btn btn-block btn-sm btn-default btn-flat border-primary" href="./index.php?page=new_letter">
<i class="fa fa-plus"></i> Add New project
<i class="fa fa-plus"></i> Add New letter
</a>
</div>
<?php endif; ?>
Expand Down Expand Up @@ -53,7 +53,7 @@
$qry = $conn->query("SELECT * FROM gpd_letters $where order by letter_creator_user_id asc");
while($row = $qry->fetch_assoc()):
$status = $row['letter_status'];
$prog = ($status == 4) ? 100 : ($status * 25); // Assuming Done is 100%
$prog = ($status == 4) ? 100 : ($status * 20); // Assuming Done is 100%

?>
<tr>
Expand All @@ -74,10 +74,10 @@
Action
</button>
<div class="dropdown-menu" style="">
<a class="dropdown-item view_project" href="./index.php?page=view_project&id=<?php echo $row['letter_id'] ?>" data-id="<?php echo $row['letter_id'] ?>">View</a>
<a class="dropdown-item view_project" href="./index.php?page=view_letter&id=<?php echo $row['letter_id'] ?>" data-id="<?php echo $row['letter_id'] ?>">View</a>
<?php if($_SESSION['login_user_type_id'] != 4 | $_SESSION['login_user_type_id'] != 5 ): ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="./index.php?page=edit_project&id=<?php echo $row['letter_id'] ?>">Edit</a>
<a class="dropdown-item" href="./index.php?page=edit_letter&id=<?php echo $row['letter_id'] ?>">Edit</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item delete_project" href="javascript:void(0)" data-id="<?php echo $row['letter_id'] ?>">Delete</a>
<?php endif; ?>
Expand Down
9 changes: 3 additions & 6 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<link rel="icon" href="./assets/images/favicon.png" type="image/png" />
<style>
body {
background-image: url('/assets/images/gpdbackground.jpg'); /* Replace 'background.jpg' with the path to your background image */
background-size: cover; /* Cover the entire background */
background-image: url('./assets/images/gpdbackground.jpg'); /* Replace 'background.jpg' with the path to your background image */
background-size: cover;
}
.overlay {
position: absolute;
Expand Down Expand Up @@ -38,7 +38,7 @@
<body style="background-image: url('./assets/images/gpdbackground.jpg');" class="hold-transition login-page bg-black overlay">
<div class="login-box">
<div class="login-logo">
<a href="#" class="text-black"><b><?php echo $_SESSION['system']['name'] ?> - Admin</b></a>
<a href="#" class="text-black"><b><?php echo $_SESSION['system']['name'] ?></b></a>
</div>
<!-- /.login-logo -->
<div class="card">
Expand Down Expand Up @@ -69,15 +69,12 @@
</label>
</div>
</div>
<!-- /.col -->
<div class="col-4">
<button type="submit" class="btn btn-primary btn-block">Sign In</button>
</div>
<!-- /.col -->
</div>
</form>
</div>
<!-- /.login-card-body -->
</div>
</div>
<!-- /.login-box -->
Expand Down
60 changes: 23 additions & 37 deletions manage_task.php
Original file line number Diff line number Diff line change
@@ -1,58 +1,41 @@
<?php
$stat = array("teacher","hod","lipik","principal");
include 'db_connect.php';
session_start();
if(isset($_GET['id'])){
$qry = $conn->query("SELECT * FROM task_list where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
$qry = $conn->query("SELECT * FROM gpd_letters where letter_id = ".$_GET['id']);
$row = $qry->fetch_assoc();
foreach($row as $k => $v){
$$k = $v;
}
}
?>



<div class="container-fluid">
<form action="" id="manage-task">
<input type="hidden" name="id" value="<?php echo isset($id) ? $id : '' ?>">
<input type="hidden" name="project_id" value="<?php echo isset($_GET['pid']) ? $_GET['pid'] : '' ?>">
<div class="form-group">
<label for="">Task</label>
<input type="text" class="form-control form-control-sm" name="task" value="<?php echo isset($task) ? $task : '' ?>" required>
</div>
<div class="form-group">
<label for="">Description</label>
<textarea name="description" id="" cols="30" rows="10" class="summernote form-control">
<?php echo isset($description) ? $description : '' ?>
</textarea>
</div>
<input type="hidden" name="letter_id" value="<?php echo isset($_GET['pid']) ? $_GET['pid'] : '' ?>">
<div class="form-group">
<label for="">Status</label>
<select name="status" id="status" class="custom-select custom-select-sm">
<option value="1" <?php echo isset($status) && $status == 1 ? 'selected' : '' ?>>Pending</option>
<option value="2" <?php echo isset($status) && $status == 2 ? 'selected' : '' ?>>On-Progress</option>
<option value="3" <?php echo isset($status) && $status == 3 ? 'selected' : '' ?>>Done</option>
</select>
<label for="">Remark</label>
<input type="text" class="form-control form-control-sm" name="<?php echo 'letter_'.$stat[$_SESSION['login_user_type_id'] - 2].'_remarks'; ?>" value="<?php echo isset($row['letter_'.$stat[$_SESSION['login_user_type_id'] - 2].'_remarks']) ? $row['letter_'.$stat[$_SESSION['login_user_type_id'] - 2].'_remarks'] : ''; ?>" required>
</div>
<input type="hidden" name="letter_status" value="<?php echo $row['letter_status'] + 1 ?>">
</form>
</div>

<script>
$(document).ready(function(){
<script>




$('.summernote').summernote({
height: 200,
toolbar: [
[ 'style', [ 'style' ] ],
[ 'font', [ 'bold', 'italic', 'underline', 'strikethrough', 'superscript', 'subscript', 'clear'] ],
[ 'fontname', [ 'fontname' ] ],
[ 'fontsize', [ 'fontsize' ] ],
[ 'color', [ 'color' ] ],
[ 'para', [ 'ol', 'ul', 'paragraph', 'height' ] ],
[ 'table', [ 'table' ] ],
[ 'view', [ 'undo', 'redo', 'fullscreen', 'codeview', 'help' ] ]
]
})
})

$('#manage-task').submit(function(e){
e.preventDefault()
var formData = new FormData($(this)[0]);
formData.forEach(function(value, key){
console.log(key + ": " + value);
});

start_load()
$.ajax({
url:'ajax.php?action=save_task',
Expand All @@ -63,12 +46,15 @@
method: 'POST',
type: 'POST',
success:function(resp){
console.log(resp);

if(resp == 1){
alert_toast('Data successfully saved',"success");
setTimeout(function(){
location.reload()
},1500)
}

}
})
})
Expand Down
23 changes: 16 additions & 7 deletions manage_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@
<div id="msg"></div>

<form action="" id="manage-user">
<input type="hidden" name="id" value="<?php echo isset($meta['id']) ? $meta['id']: '' ?>">
<input type="hidden" name="user_id" value="<?php echo isset($meta['user_id']) ? $meta['user_id']: '' ?>">
<div class="form-group">
<label for="name">First Name</label>
<input type="text" name="firstname" id="firstname" class="form-control" value="<?php echo isset($meta['firstname']) ? $meta['firstname']: '' ?>" required>
<input type="text" name="user_name" id="firstname" class="form-control" value="<?php echo isset($meta['user_name']) ? $meta['user_name']: '' ?>" required>
</div>
<div class="form-group">
<label for="name">Last Name</label>
<input type="text" name="lastname" id="lastname" class="form-control" value="<?php echo isset($meta['lastname']) ? $meta['lastname']: '' ?>" required>
<input type="text" name="user_surname" id="lastname" class="form-control" value="<?php echo isset($meta['user_surname']) ? $meta['user_surname']: '' ?>" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="text" name="email" id="email" class="form-control" value="<?php echo isset($meta['email']) ? $meta['email']: '' ?>" required autocomplete="off">
<input type="text" name="user_email" id="email" class="form-control" value="<?php echo isset($meta['user_email']) ? $meta['user_email']: '' ?>" required autocomplete="off">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" id="password" class="form-control" value="" autocomplete="off">
<input type="password" name="user_password" id="password" class="form-control" value="" autocomplete="off">
<small><i>Leave this blank if you dont want to change the password.</i></small>
</div>
<div class="form-group">
<label for="" class="control-label">Avatar</label>
<label for="" class="control-label">user profile</label>
<div class="custom-file">
<input type="file" class="custom-file-input rounded-circle" id="customFile" name="img" onchange="displayImg(this,$(this))">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
</div>
<div class="form-group d-flex justify-content-center">
<img src="<?php echo isset($meta['avatar']) ? 'assets/uploads/'.$meta['avatar'] :'' ?>" alt="" id="cimg" class="img-fluid img-thumbnail">
<img src="<?php echo isset($meta['user_profile_pic']) ? 'assets/uploads/'.$meta['user_profile_pic'] :'' ?>" alt="" id="cimg" class="img-fluid img-thumbnail">
</div>


Expand All @@ -63,6 +63,14 @@ function displayImg(input,_this) {
reader.readAsDataURL(input.files[0]);
}
}


var email = $('#email').val().trim();
var password = $('#password').val().trim();

// Set trimmed values back to the input fields
$('#email').val(email);
$('#password').val(password);
$('#manage-user').submit(function(e){
e.preventDefault();
start_load()
Expand All @@ -75,6 +83,7 @@ function displayImg(input,_this) {
method: 'POST',
type: 'POST',
success:function(resp){
console.log(resp);
if(resp ==1){
alert_toast("Data successfully saved",'success')
setTimeout(function(){
Expand Down
7 changes: 6 additions & 1 deletion new_letter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php if(!isset($conn)){ include 'db_connect.php'; }

if (isset($letter_id)) {
$qry = $conn->query("SELECT * FROM gpd_users WHERE user_id = (SELECT letter_creator_user_id FROM gpd_letters WHERE letter_id = $letter_id)");
$row2 = $qry->fetch_assoc();
}
?>
<div class="col-lg-12">
<div class="card card-outline card-primary">
Expand All @@ -10,7 +15,7 @@
<div class="col-md-6">
<div class="form-group">
<label for="" class="control-label">Name</label>
<input type="text" class="form-control form-control-sm" name="name" value="<?php echo isset( $_SESSION["login_user_name"]) ? $_SESSION["login_user_name"]." ".$_SESSION["login_user_surname"] : '' ?>" readonly>
<input type="text" class="form-control form-control-sm" name="name" value="<?php echo isset( $row2["user_name"]) ? $row2["user_name"]." ".$row2["user_surname"] : '' ?>" readonly>
</div>
</div>
<div class="col-md-6">
Expand Down
Loading

0 comments on commit b3c1e65

Please sign in to comment.