ok
Direktori : /home/ngwcolle/public_html/mis/admin/ |
Current File : //home/ngwcolle/public_html/mis/admin/income.php |
<?php include('includes/checklogin.php'); check_login(); error_reporting(1); if($_POST['id']){ $id=$_POST['id']; $response = array(); $select=$dbh->prepare("select * from tblaccount where id = :ppid"); $select->bindParam(':ppid',$id); $select->execute(); $row=$select->fetch(PDO::FETCH_ASSOC); if($select -> rowCount() > 0) { $response=$row; } else { $response = null; } // header('Content-Type: application/json'); echo json_encode($response); exit; } if (isset($_POST['submit'])) { $txdate = $_POST['tdate']; $txamount = $_POST['amtpaid']; $txtype = "Cr"; $accounthead = $_POST['acchead']; $paidto = $_POST['details']; $remark = $_POST['reference']; // $aimage = $_FILES["animalimage"]["name"]; // move_uploaded_file($_FILES["animalimage"]["tmp_name"], "images/" . $_FILES["animalimage"]["name"]); $sql = "INSERT INTO tbltrans(txdate,txamount,txtype,accounthead,paidto,remark) VALUES(:aname,:cage,:feed,:breed,:adetails,:aimage)"; $query = $dbh->prepare($sql); $query->bindParam(':aname', $txdate, PDO::PARAM_STR); $query->bindParam(':cage', $txamount, PDO::PARAM_STR); $query->bindParam(':feed', $txtype, PDO::PARAM_STR); $query->bindParam(':breed', $accounthead, PDO::PARAM_STR); $query->bindParam(':adetails', $paidto, PDO::PARAM_STR); $query->bindParam(':aimage', $remark, PDO::PARAM_STR); $query->execute(); $lastInsertId = $dbh->lastInsertId(); if ($lastInsertId) { $count = $dbh->prepare("select * from tbltrans "); //$count=$dbo->prepare("delete from pdo_admin where status='F'"); $count->execute(); $no = "NGWCR".str_pad($count->rowCount(),5,0,STR_PAD_LEFT); $msg = "Animal Created Successfully"; $sql2 ="UPDATE tbltrans set txid = '$no' where id='$lastInsertId'"; $dbh->exec($sql2); $sql1 ="UPDATE tblaccount set amtbalance = amtbalance+'$txamount' where id='$accounthead'"; $dbh->exec($sql1); // exit(); echo '<script>alert("Collection Addedd Successfully.")</script>'; echo "<script>window.location.href ='manage_income.php'</script>"; } else { $error = "Something went wrong. Please try again"; } } ?> <!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=""> <link href="img/logo/logo.png" rel="icon"> <title>Admin - Create Income</title> <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"> <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"> <link href="css/ruang-admin.min.css" rel="stylesheet"> <style> .errorWrap { padding: 10px; margin: 0 0 20px 0; background: #fff; border-left: 4px solid #dd3d36; -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1); box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1); } .succWrap { padding: 10px; margin: 0 0 20px 0; background: #fff; border-left: 4px solid #5cb85c; -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1); box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1); } </style> </head> <body id="page-top"> <div id="wrapper"> <!-- Sidebar --> <?php include('includes/sidebar.php'); ?> <!-- Sidebar --> <div id="content-wrapper" class="d-flex flex-column"> <div id="content"> <!-- TopBar --> <?php include('includes/header.php'); ?> <!-- Topbar --> <!-- Container Fluid--> <div class="container-fluid" id="container-wrapper"> <div class="d-sm-flex align-items-center justify-content-between mb-4"> <h1 class="h3 mb-0 text-gray-800">Collection</h1> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="dashboard.php">Home</a></li> <li class="breadcrumb-item active" aria-current="page">Add Collection Detail</li> </ol> </div> <div class="row"> <div class="col-lg-12"> <!-- Form Basic --> <div class="card mb-4"> <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between"> <h6 class="m-0 font-weight-bold text-primary">Register New Collection</h6> </div> <div class="card-body"> <?php if ($error) { ?> <div class="errorWrap"> <strong>ERROR</strong>:<?php echo htmlentities($error); ?> </div> <?php } else if ($msg) { ?> <div class="succWrap"> <strong>SUCCESS</strong>:<?php echo htmlentities($msg); ?> </div> <?php } ?> <form class="form-sample" method="post" enctype="multipart/form-data"> <div class="row "> <div class="form-group col-md-8 pl-md-0"> <label class="col-sm-12 pl-0 pr-0">Collected to the Head of Account</label> <div class="col-sm-12 pl-0 pr-0"> <select name="acchead" id="acchead" class="form-control bg-light"> <option value="">--Select Account Head--</option> <?php $smt = $dbh->prepare("select * from tblaccount where status='1'"); $smt->execute(); $data = $smt->fetchAll(PDO::FETCH_OBJ); foreach ($data as $row){ ?> <option value="<?php echo $row->id;?>"><?php echo strtoupper($row->accounthead);?></option> <?php }?> </select> <!-- <input type="text" class="form-control" name="animalname" id="animalname" placeholder="Animal Name" required> --> </div> </div> <div class="form-group col-md-4 pl-md-0"> <label class="col-sm-12 pl-0 pr-0">Balance Fund</label> <div class="col-sm-12 pl-0 pr-0"> <input type="text" name="balance" id="balance" placeholder="Balance Fund" class="form-control text-danger" readonly> </div> </div> </div> <div class="row"> <div class="form-group col-md-6 pl-md-0"> <label class="col-sm-12 pl-0 pr-0">Transaction Date</label> <div class="col-sm-12 pl-0 pr-0"> <input type="date" class="form-control" name="tdate" id="cage" placeholder="Date" required> </div> </div> <div class="form-group col-md-6 pl-md-0"> <label class="col-sm-12 pl-0 pr-0">Amount Collected/Allottment Received(In Rs.)</label> <div class="col-sm-12 pl-0 pr-0"> <input type="text" class="form-control" name="amtpaid" id="amtpaid" placeholder="Amount Paid in Rs." required> </div> </div> <!-- <div class="form-group col-md-6 pl-md-0"> <label class="col-sm-12 pl-0 pr-0">Breed</label> <div class="col-sm-12 pl-0 pr-0"> <input type="text" class="form-control" name="breed" id="breed" placeholder=" Breed" required> </div> </div> --> </div> <div class="row"> <div class="form-group col-md-6 pl-md-0"> <label class="col-sm-12 pl-0 pr-0">Collection Details</label> <div class="col-sm-12 pl-0 pr-0"> <textarea class="form-control" rows="5" cols="50" name="details" id="details" placeholder="Expense Details" required></textarea> </div> </div> <div class="form-group col-md-6 pl-md-0 "> <label class="col-sm-12 pl-0 pr-0 ">Cheque/DD/UPI/TV/UTR No with Date</label> <div class="col-sm-12 pl-0 pr-0"> <textarea class="form-control" rows="5" cols="50" name="reference" id="details" placeholder="Transaction Reference Details" required></textarea> </div> </div> </div> <button type="submit" name="submit" id="btnSubmit" class="btn-primary btn">Create</button> <button type="reset" class="btn-inverse btn">Reset</button> </form> </div> </div> </div> </div> <!--Row--> <!-- Modal Logout --> <?php include('includes/modal.php'); ?> </div> <!---Container Fluid--> </div> <!-- Footer --> <?php include('includes/footer.php'); ?> <!-- Footer --> </div> </div> <!-- Scroll to top --> <a class="scroll-to-top rounded" href="#page-top"> <i class="fas fa-angle-up"></i> </a> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="vendor/jquery-easing/jquery.easing.min.js"></script> <script src="js/ruang-admin.min.js"></script> <script> $(document).ready(function(){ $("#btnSubmit").click(function(){ var balance=$('#balance').val(); if(parseInt(balance)<0){ alert("Not sufficient fund in this head"); return false; } }); $('#pin,#amtpaid,#distance,#whno,#stmobile,#gcontact,#aadhar').keypress(function (e) { // var charCode = (e.which) ? e.which : event.keyCode // if (String.fromCharCode(charCode).match(/[^0-9]/g)) // return false; var caret = e.target.selectionStart; var nowStr = $(this).val().substr(0, caret) + String.fromCharCode(e.which) + $(this).val().substr(caret); if (!$.isNumeric(nowStr)) e.preventDefault(); }); $("#acchead").change(function(){ var selectedCountry = $(this).children("option:selected").val(); // var admyear = $('#admyear').children("option:selected").val(); // alert("You have selected the country - " + admyear); if (!$('#acchead').val()) { alert('Select Account Head!'); return false; } // alert(selectedCountry); // ajax call $.ajax ({ method:"POST", url: "expense.php", // data: sub_id, // data:'subid='+sub_id, data: {id:selectedCountry}, dataType:"json", cache: false, success: function(response) { if(response){ $("#balance").val(response['amtbalance']); } console.log(response); } }); // ajax return }); }); </script> </body> </html>