ok

Mini Shell

Direktori : /proc/self/root/home/ngwcolle/www/LIBRARY-NGWC/admin/
Upload File :
Current File : //proc/self/root/home/ngwcolle/www/LIBRARY-NGWC/admin/credit-history.php

<?php session_start();
//DB conncetion
date_default_timezone_set('Asia/Kolkata');
include_once('includes/config.php');
error_reporting(0);
//validating Session
if (strlen($_SESSION['aid']==0)) {
  header('location:logout.php');
  } else{

//Code for record deletion
if($_GET['teamid']){
$tid=$_GET['teamid'];
mysqli_query($con,"delete from tblteams where id ='$tid'");
echo "<script>alert('Data Deleted');</script>";
echo "<script>window.location.href='manage-teams.php'</script>";
          }
          
        //   $school_number = $_GET['school_number'];
        //   $user_query = mysqli_query($con,"SELECT * FROM tbl_students WHERE rollno = '$school_number' ");
        //   $user_row = mysqli_fetch_array($user_query);
          //get current login user name
          $adid=$_SESSION['aid'];
$ret1=mysqli_query($con,"select AdminName from tbladmin where ID='$adid'");
while($row1=mysqli_fetch_array($ret1)){
    $cuser=$row1['AdminName'];
}
          // add deprmtnet
          if(isset($_POST['submit']))
          {
            $tname=strtoupper($_POST['dname']);
            $tlname=$_POST['cno'];
          $mobno=strtoupper($_POST['scode']);
        //   $tmember=$_POST['teammember'];
        $query=mysqli_query($con, "insert into tbl_department(name,shortcode,classno) values('$tname','$mobno','$tlname')");
        if ($query) {
        echo '<script>alert("Department Created.")</script>';
        echo "<script>window.location.href ='manage-department.php'</script>";
          }else{
        echo '<script>alert("Something Went Wrong. Please try again.")</script>';
            }
        }
          //end addition
?>
<!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, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Credit History</title>
    <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> 
    <!-- Custom fonts for this template -->
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link
        href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
        rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/sb-admin-2.min.css" rel="stylesheet">

    <!-- Custom styles for this page -->
    <link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">

</head>

<body id="page-top">

    <!-- Page Wrapper -->
    <div id="wrapper">

        <!-- Sidebar -->
  <?php include_once('includes/sidebar.php');?>
        <!-- End of Sidebar -->

        <!-- Content Wrapper -->
        <div id="content-wrapper" class="d-flex flex-column">

            <!-- Main Content -->
            <div id="content">

                <!-- Topbar -->
<?php include_once('includes/topbar.php');?>
                <!-- End of Topbar -->

                <!-- Begin Page Content -->
                <div class="container-fluid">

                    <!-- Page Heading -->
                       <div class="d-sm-flex align-items-center justify-content-between mb-4">
                        <h1 class="h3 mb-0 text-gray-800">Patron Credit History</h1>
                
                    </div>
                        <!-- DataTales Example -->
                        <?php
						$sql = mysqli_query($con,"SELECT  tbl_students.*,tbl_department.* FROM tbl_students INNER JOIN tbl_department ON tbl_students.department=tbl_department.id WHERE tbl_students.rollno = '$school_number' ");
						$row = mysqli_fetch_array($sql);
					?>
                    <div class="card shadow mb-4">
                        <div class="card-header py-3">
                          <div class="float-left">  <h6 class="m-0 py-2 font-weight-bold text-primary">
                          Search Credit History
                          </h6>
                        <input type="hidden" name="cuser" value="<?php echo $cuser;?>"/>  
                        </div>
                            <div class="float-right"><a href="dashboard.php" class="float-right mt-0 btn btn-success">Back</a></div>
                        </div>
                        
                        <div class="card-body">
                             <!-- issue area starts -->
                       <div class="row" style="margin-top:30px;" >
                       <form method="post">
							<div class="col-xs-4 p-4">
								<input type="text" style="margin-bottom:10px; margin-left:-9px;" class="form-control" name="barcode" placeholder="Enter Roll no/ID here....." autofocus required />
							</div>
						</form>
                        </div>
                       <!-- issue area ends` -->
                       <!-- outstanding area -->
                       <div class="table-responsive">
                                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th>Barcode</th>
                                            <th>Book Title</th>
                                            <th>Author </th>
                                            <th>ISBN</th>
                                            <th>Date Borrowed</th>
                                            <th>Due Date</th>
                                            <th>Penalty</th>
                                             <!-- <th>Reporting Time</th> -->
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <!-- <tfoot>
                                     <tr>
                                            <th>Sno.</th>
                                            <th>Name</th>
                                            <th>Mobile Number</th>
                                            <th>Location </th>
                                             <th>Message</th>
                                             <th>Reporting Time</th>
                                            <th>Action</th>
                                        </tr>
                                    </tfoot> -->
                                    <tbody>
<?php
//  $barcode = $_GET['barcode'];
if(isset($_POST['barcode'])){
$barcode = strtoupper($_POST['barcode']);
$_SESSION['id']=$barcode;
$query=mysqli_query($con,"select tbl_book.*,borrow_book.* from borrow_book inner join tbl_book on borrow_book.book_id=tbl_book.barcode where user_id='".$_SESSION['id']."' and borrowed_status='borrowed'");
$cnt=1;
$borrow_count = mysqli_num_rows($query);
while($row=mysqli_fetch_array($query)){
    $timezone = "Asia/Kolkata";
	if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
    $due_date= $row['due_date'];
    $date_returned = date("Y-m-d H:i:s");
    $penalty_amount_query= mysqli_query($con,"select * from settings") or die (mysqli_error());
	$penalty_amount = mysqli_fetch_assoc($penalty_amount_query);
	if($date_returned > $due_date) {
	$penalty = round((float)(strtotime($date_returned) - strtotime($due_date)) / (60 * 60 *24) * ($penalty_amount['penalty_amount']));
	} elseif ($date_returned < $due_date) {
	$penalty = 'No Penalty';
	} else {
	$penalty = 'No Penalty';
	}
?>

                                        <tr>
                                            
                                            <td><?php echo $row['barcode'];?></td>
                                            <td><?php echo $row['booktitle'];?></td>
                                            <td><?php echo $row['author1'];?></td>
                                            <td><?php echo $row['isbn'];?></td>
                                            <td><?php echo $row['date_borrowed'];?></td>
                                            <td><?php echo $row['due_date'];?></td>
                                           
                                            <?php
									if ($borrow_row['status'] != 'Hardbound') {
										echo "<td>".$penalty."</td>";
									} else {
										echo "<td>".'Hardbound Book, Inside Library Issue Only'."</td>";
									}
								?>
                                            <td>
                                            <form method="post" action="">
								<input type="hidden" name="date_returned" class="new_text" id="sd" value="<?php echo $date_returned ?>" size="16" maxlength="10"  />
								<input type="hidden" name="user_id" value="<?php echo $row['user_id']; ?>">
								<input type="hidden" name="borrow_book_id" value="<?php echo $row['borrow_book_id']; ?>">
								<input type="hidden" name="book_id" value="<?php echo $row['book_id']; ?>">
								<input type="hidden" name="date_borrowed" value="<?php echo $row['date_borrowed']; ?>">
								<input type="hidden" name="due_date" value="<?php echo $row['due_date']; ?>">
								<button name="return" class="btn btn-sm btn-danger"><i class="fa fa-arrow-down"></i> Return</button>
								</form>
                                

                              </td>
                                        </tr>
                               <?php $cnt++;
                           } }?>
                           <?php
							if ($borrow_count <= 0){
								echo '
									<table style="float:right;">
										<tr>
											<td style="padding:10px;" class="alert alert-danger">No books borrowed</td>
										</tr>
									</table>
								';
							}
							?>
                            <!-- return area starts -->
                            <?php
								if (isset($_POST['return'])) {
									$user_id= $_POST['user_id'];
									$borrow_book_id= $_POST['borrow_book_id'];
									$book_id= $_POST['book_id'];
									$date_borrowed= $_POST['date_borrowed'];
									$due_date= $_POST['due_date'];
									$date_returned = $_POST['date_returned'];
                                    $update_copies = mysqli_query($con,"SELECT * from tbl_book where barcode = '$book_id' ") or die (mysqli_error());
									$copies_row= mysqli_fetch_assoc($update_copies);
									$book_copies = $copies_row['nocopies'];
									$new_book_copies = $book_copies + 1;
                                    if ($new_book_copies == '0') {
										$remark = 'Not Available';
									} else {
										$remark = 'Available';
									}
                                    mysqli_query($con,"UPDATE tbl_book SET nocopies = '$new_book_copies' where barcode = '$book_id'") or die (mysqli_error());
									mysqli_query($con,"UPDATE tbl_book SET remarks = '$remark' where barcode = '$book_id' ") or die (mysqli_error());
                                    $timezone = "Asia/Kolkata";
									if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
									$cur_date = date("Y-m-d H:i:s");
									$date_returned_now = date("Y-m-d H:i:s");
                                    $penalty_amount_query= mysqli_query($con,"select * from settings") or die (mysqli_error());
									$penalty_amount = mysqli_fetch_assoc($penalty_amount_query);
                                    if ($date_returned > $due_date) {
										$penalty = round((float)(strtotime($date_returned) - strtotime($due_date)) / (60 * 60 *24) * ($penalty_amount['penalty_amount']));
									} elseif ($date_returned < $due_date) {
										$penalty = 'No Penalty';
									} else {
										$penalty = 'No Penalty';
									}

                                    mysqli_query($con,"UPDATE borrow_book SET borrowed_status = 'returned', date_returned = '$date_returned_now', book_penalty = '$penalty' WHERE borrow_book_id= '$borrow_book_id' and user_id = '$user_id' and book_id = '$book_id' ") or die (mysqli_error());

									mysqli_query($con,"INSERT INTO return_book (user_id, book_id, barcode,date_borrowed, due_date, date_returned, book_penalty)
									values ('$user_id', '$borrow_book_id','$book_id','$date_borrowed', '$due_date', '$date_returned', '$penalty')") or die (mysqli_error());
                                    mysqli_query($con,"INSERT INTO report(book_id, user_id, admin_name, detail_action, date_transaction)
                                    VALUES ('$book_id','$user_id','$cuser','Returned Book',NOW())") or die(mysqli_error());
                                    echo '<script>alert("Book Successfully collected from Patron!!!")</script>';
									

									
							?>
									<script>
										window.location="credit-history.php";
									</script>
							<?php
																}
							?>
                            <!-- return area ends -->
                                    </tbody>
                                </table>
                            </div>
                       <!-- outstanding area ends -->
                      
                        </div>
                    </div>

                </div>
                <!-- /.container-fluid -->

            </div>
            <!-- End of Main Content -->

            <!-- Footer -->
    <?php include_once('includes/footer.php');?>
            <!-- End of Footer -->

        </div>
        <!-- End of Content Wrapper -->

    </div>
    <!-- End of Page Wrapper -->

    <!-- Scroll to Top Button-->
    <?php include_once('includes/footer2.php');?>

    <!-- Bootstrap core JavaScript-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>

    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin-2.min.js"></script>

    <!-- Page level plugins -->
    <script src="vendor/datatables/jquery.dataTables.min.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>

    <!-- Page level custom scripts -->
    <script src="js/demo/datatables-demo.js"></script>
</body>
</html>
<?php } ?>

Zerion Mini Shell 1.0